提交 6ff103d4 编写于 作者: N Nicolas Hennion

Command improvment

上级 676fb699
...@@ -82,7 +82,7 @@ mem_critical=90 ...@@ -82,7 +82,7 @@ mem_critical=90
# An item is defined: # An item is defined:
# * description: Description of the processes (max 16 chars) # * description: Description of the processes (max 16 chars)
# * regex: regular expression of the processes to monitor # * regex: regular expression of the processes to monitor
# * command: (optional) shell command for extended stat # * command: (optional) full path to shell command/script for extended stat
# Use with caution. Should return a single line string. # Use with caution. Should return a single line string.
# * countmin: (optional) minimal number of processes # * countmin: (optional) minimal number of processes
# A warning will be displayed if number of process < count # A warning will be displayed if number of process < count
...@@ -90,7 +90,7 @@ mem_critical=90 ...@@ -90,7 +90,7 @@ mem_critical=90
# A warning will be displayed if number of process > count # A warning will be displayed if number of process > count
list_1_description=Redis server list_1_description=Redis server
list_1_regex=.*redis-server.* list_1_regex=.*redis-server.*
list_1_command=redi s-cli CLIENT LIST list_1_command=echo STAT
list_2_description=Python programs list_2_description=Python programs
list_2_regex=.*python.* list_2_regex=.*python.*
list_2_countmin=1 list_2_countmin=1
......
...@@ -3064,8 +3064,11 @@ class glancesScreen: ...@@ -3064,8 +3064,11 @@ class glancesScreen:
monitors.countmax(item))) monitors.countmax(item)))
# Build and print optional message # Build and print optional message
if (monitors.command(item) != None): if (monitors.command(item) != None):
monitormsg2 = "{0}".format( try:
subprocess.check_output(monitors.command(item), shell = True) if monitors.command(item) != "" else "") cmdret = subprocess.check_output(monitors.command(item), shell = True)
except subprocess.CalledProcessError:
cmdret = _("Error: ") + monitors.command(item)
monitormsg2 = "{0}".format(cmdret)
self.term_window.addnstr(monitor_y, self.process_x + 35, self.term_window.addnstr(monitor_y, self.process_x + 35,
monitormsg2, screen_x - process_x - 35) monitormsg2, screen_x - process_x - 35)
# else: # else:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册