aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-10-04 02:48:14 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-10-04 02:48:14 +0300
commitd5f28ec385ca5bc7f5bedb3e735a9af88129197d (patch)
tree031b09ec6f9e56fd680ad83f60a9526c8f5de712
parentdebian: 1.0.1-1 (diff)
parenttop: run with -E/-e if supported (diff)
downloadlinux-status-d5f28ec385ca5bc7f5bedb3e735a9af88129197d.tar.gz
linux-status-d5f28ec385ca5bc7f5bedb3e735a9af88129197d.zip
Merge tag 'v1.1.0' into debian
-rwxr-xr-xapp.py19
-rw-r--r--index.html2
2 files changed, 19 insertions, 2 deletions
diff --git a/app.py b/app.py
index b4d2967..1ae9760 100755
--- a/app.py
+++ b/app.py
@@ -207,8 +207,10 @@ class Task(abc.ABC):
class TopTask(Task):
+ COMMAND = None
+
def __init__(self):
- self.cmd = Command('top', '-b', '-n', '1', '-w', '512')
+ self.cmd = TopTask.get_command()
def run(self):
self.task = self.cmd.run()
@@ -216,6 +218,21 @@ class TopTask(Task):
def result(self):
return self.task.result()
+ @staticmethod
+ def get_command():
+ # On more modern versions of top, we want to enable memory scaling
+ # from the command line (another option is the rc file, but that's too
+ # complicated). For that, we simply run `top -h` once, and check if
+ # the output contains the flags we want to use.
+ if TopTask.COMMAND is not None:
+ return TopTask.COMMAND
+ help_output = run_do('top', '-h')
+ args = ['top', '-b', '-n', '1', '-w', '512']
+ if 'Ee' in help_output:
+ args += ['-E', 'm', '-e', 'm']
+ TopTask.COMMAND = Command(*args)
+ return TopTask.COMMAND
+
class RebootTask(Task):
def __init__(self):
diff --git a/index.html b/index.html
index 7c8c542..52a45fc 100644
--- a/index.html
+++ b/index.html
@@ -125,7 +125,7 @@ function create_user_block(name, lbl, cmd) {
};
return $('<div/>')
.append($('<p/>')
- .append($('<button/>', button_params).text('+'))
+ .append($('<button/>', button_params).text('+'))
.append($('<a/>', a_params)
.append($('<code/>').text(cmd))))
.append($('<div/>', {'class': 'collapse', id: collapse_id})