This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository mum. See http://git.chorem.org/mum.git commit 243bf5116c0495ab5477ddaece0ca02f002bdbf0 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Feb 26 12:57:10 2015 +0100 the monitoring can now resume after launching again the server --- app/app.py | 6 +++--- app/module_loader.py | 15 ++++++++++++++- app/modules/storage_modules/shelve_db.py | 18 ++++++++++++++++-- app/process_monitoring.py | 16 +++++++++++++--- requirements.txt | 3 +-- 5 files changed, 47 insertions(+), 11 deletions(-) diff --git a/app/app.py b/app/app.py index 9c22377..8a51703 100755 --- a/app/app.py +++ b/app/app.py @@ -141,11 +141,11 @@ def receive(ws): else: break except: # Should be WebSocketError when closing the connection - break + pass # Lancement du serveur a l'adresse 0.0.0.0:1337 if __name__ == '__main__': - process_monitoring.init() + process_monitoring.init(module_loader.load_db()) port = int(os.environ.get('PORT', 1337)) - run(host='0.0.0.0', port=port, debug=True, reloader=True, server=GeventWebSocketServer) \ No newline at end of file + run(host='0.0.0.0', port=port, debug=True, server=GeventWebSocketServer) \ No newline at end of file diff --git a/app/module_loader.py b/app/module_loader.py index f1ded30..93913d3 100644 --- a/app/module_loader.py +++ b/app/module_loader.py @@ -175,4 +175,17 @@ def create_global_conf(db): dict_mod = {} for os in modules.monitoring_modules.__all__: dict_mod[os] = get_info_mod_monitoring() - db.create_global_conf(dict_mod) \ No newline at end of file + db.create_global_conf(dict_mod) + + +def get_all_monitoring_instructions(db): + """ + runs on the database the function get_monitoring_instructions for all hosts under monitoring + :param db: the database to perform operation + :return:the monitoring instructions for all hosts + """ + res = [] + for addr_host in db.get_list_addr_hosts(): + for instr in db.get_monitoring_instructions(addr_host): + res.append(instr) + return res \ No newline at end of file diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index aab9e92..5d1bea7 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -145,13 +145,13 @@ class shelve_db: Necessary to launch for the first time all activated monitoring modules for a given host :param addr_host: the address IP of the host :return: structured informations about monitoring in form : - { + [{ 'addr' : val, => the IP address of the host 'os', val, => the operating system of the host 'mod_name', val, => the name of the monitoring module 'time', val, => the time at when to launch the monitoring module 'freq', val => the frequency check (in seconds) - } + }, ...] """ self.open_db() res = [] @@ -169,6 +169,20 @@ class shelve_db: self.close_db() return res + def get_list_addr_hosts(self): + """ + Necessary when running again the application, for getting the monitoring instructions for all hosts + :return: a list containing all the IP adress of the hosts under monitoring + """ + self.open_db() + res = [] + try: + for addr_host in self.db['hosts']: + res.append(addr_host) + finally: + self.close_db() + return res + def get_hosts(self): """ Returns the essential data about all hosts under monitoring diff --git a/app/process_monitoring.py b/app/process_monitoring.py index c9f03b8..44098da 100644 --- a/app/process_monitoring.py +++ b/app/process_monitoring.py @@ -4,14 +4,24 @@ import threading from datetime import datetime from datetime import timedelta from module_loader import run_one_monitoring_module +from module_loader import get_all_monitoring_instructions import time import sys waiting_list = [] +launched = False -def init(): - pm = ProcessMonitoring() - pm.start() +def init(db): + global launched + if not launched: + print get_all_monitoring_instructions(db) + for instr in get_all_monitoring_instructions(db): + #print "adding : " + str(instr) + sys.stdout.flush() + add_to_waiting_list(instr) + pm = ProcessMonitoring() + pm.start() + launched = True class ProcessMonitoring(threading.Thread): diff --git a/requirements.txt b/requirements.txt index b689fc6..3cef053 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ bottle==0.12.7 -pysnmp pexpect paramiko -bottle-websocket \ No newline at end of file +bottle-websocket -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.