diff --git a/docs/glances-doc.rst b/docs/glances-doc.rst index 5f25c1d8..f9f3c994 100644 --- a/docs/glances-doc.rst +++ b/docs/glances-doc.rst @@ -439,6 +439,8 @@ If you also want to monitor the PHP-FPM daemon processes, you should add another list_1_countmin=1 list_1_countmax=20 +In the client/server mode, the list is define on the server side. A new method (getAllMonitored) is available in the API and get the JSON representation of the monitored processes list. + Logs ---- diff --git a/glances/conf/glances-with-monitored.conf b/glances/conf/glances-with-monitored.conf index c2091e20..7cf32228 100644 --- a/glances/conf/glances-with-monitored.conf +++ b/glances/conf/glances-with-monitored.conf @@ -83,17 +83,17 @@ mem_critical=90 # * description: Description of the processes (max 16 chars) # * regex: regular expression of the processes to monitor # * 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 # A warning will be displayed if number of process < count # * countmax: (optional) maximum number of processes # A warning will be displayed if number of process > count -list_1_description=Redis server -list_1_regex=.*redis-server.* -list_1_command=echo "Additional stats" +list_1_description=Stress programs +list_1_regex=.*stress.* +list_1_command=stress --version +list_1_countmin=1 +list_1_countmax=8 list_2_description=Python programs list_2_regex=.*python.* -list_2_countmin=1 -list_2_countmax=8 list_3_description=Famous Xeyes list_3_regex=.*xeyes.* diff --git a/glances/glances.py b/glances/glances.py index a1849964..c66fde9c 100644 --- a/glances/glances.py +++ b/glances/glances.py @@ -19,7 +19,7 @@ # along with this program. If not, see . __appname__ = 'glances' -__version__ = "1.7RC1" +__version__ = "1.7RC2" __author__ = "Nicolas Hennion " __licence__ = "LGPL" @@ -385,6 +385,12 @@ class monitorList: else: return None + def getAll(self): + return self.__monitor_list + + def setAll(self, newlist): + self.__monitor_list = newlist + def description(self, item): """ Return the description of the item number (item) @@ -3853,6 +3859,10 @@ class GlancesInstance(): # Return all the limits return json.dumps(limits.getAll()) + def getAllMonitored(self): + # Return the processes monitored list + return json.dumps(monitors.getAll()) + def getSystem(self): # Return operating system info # No need to update... @@ -4016,6 +4026,14 @@ class GlancesClient(): else: return serverlimits + def client_get_monitored(self): + try: + servermonitored = json.loads(self.client.getAllMonitored()) + except: + return [] + else: + return servermonitored + def client_get(self): try: stats = json.loads(self.client.getAll()) @@ -4344,9 +4362,6 @@ def main(): # Init monitor list monitors = monitorList() - # print monitors - # print "*** End debug ***" - # sys.exit(2) # Init Logs logs = glancesLogs() @@ -4380,6 +4395,11 @@ def main(): if server_limits != {}: limits.setAll(server_limits) + # Set the monitored pocesses list to the server one + server_monitored = client.client_get_monitored() + if server_monitored != []: + monitors.setAll(server_monitored) + # Start the client (CLI) loop while True: # Get server system informations