Monitored processes list is now client/server mode compatible / Add a new entry in the API to get the server monitored processes list

pull/277/merge
Nicolas Hennion 2013-08-08 17:48:51 +02:00
parent 09a8b74468
commit 2c8a6dbe34
3 changed files with 32 additions and 10 deletions

View File

@ -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
----

View File

@ -88,12 +88,12 @@ mem_critical=90
# 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.*

View File

@ -19,7 +19,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
__appname__ = 'glances'
__version__ = "1.7RC1"
__version__ = "1.7RC2"
__author__ = "Nicolas Hennion <nicolas@nicolargo.com>"
__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