branch develop updated (b097080 -> d2a9fd9)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository mum. See http://git.chorem.org/mum.git from b097080 removed known ports verification because was causing random locks on db + refactored modules to move db dependency on module_loader new e2e8ef7 response after "check now" + renamed more clearly the modules + added http module new d2a9fd9 modules that don't need a connection launched separately (ping, http, smtp) + autoconf after scan also for these ones The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit d2a9fd9c325ae5277d82afdc7854d0b76ab7c886 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Apr 22 14:02:03 2015 +0200 modules that don't need a connection launched separately (ping, http, smtp) + autoconf after scan also for these ones commit e2e8ef74d7b967c78e38084c11f10d0d8f950ddb Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Apr 22 11:59:17 2015 +0200 response after "check now" + renamed more clearly the modules + added http module Summary of changes: app/module_loader.py | 30 +++++++++++++++++----- .../{cpu.py => cpu_ssh_linux.py} | 0 app/modules/monitoring_modules/disk_snmp_linux.py | 8 +++++- .../{disk.py => disk_ssh_linux.py} | 0 app/modules/monitoring_modules/http.py | 28 ++++++++++++++++++++ .../{load.py => load_ssh_linux.py} | 0 .../monitoring_modules/memory_snmp_linux.py | 8 +++++- .../{memory.py => memory_ssh_linux.py} | 0 app/modules/monitoring_modules/ping.py | 2 +- app/modules/monitoring_modules/smtp.py | 20 +++++++++++---- app/modules/monitoring_modules/swap_snmp_linux.py | 8 +++++- .../{swap.py => swap_ssh_linux.py} | 0 ...d_packages.py => updated_packages_ssh_linux.py} | 0 app/modules/storage_modules/shelve_db.py | 5 ++-- app/mum.py | 1 + 15 files changed, 91 insertions(+), 19 deletions(-) rename app/modules/monitoring_modules/{cpu.py => cpu_ssh_linux.py} (100%) rename app/modules/monitoring_modules/{disk.py => disk_ssh_linux.py} (100%) create mode 100644 app/modules/monitoring_modules/http.py rename app/modules/monitoring_modules/{load.py => load_ssh_linux.py} (100%) rename app/modules/monitoring_modules/{memory.py => memory_ssh_linux.py} (100%) rename app/modules/monitoring_modules/{swap.py => swap_ssh_linux.py} (100%) rename app/modules/monitoring_modules/{updated_packages.py => updated_packages_ssh_linux.py} (100%) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
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 e2e8ef74d7b967c78e38084c11f10d0d8f950ddb Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Apr 22 11:59:17 2015 +0200 response after "check now" + renamed more clearly the modules + added http module --- app/module_loader.py | 5 +++-- .../monitoring_modules/{cpu.py => cpu_ssh_linux.py} | 0 app/modules/monitoring_modules/disk_snmp_linux.py | 8 +++++++- .../monitoring_modules/{disk.py => disk_ssh_linux.py} | 0 app/modules/monitoring_modules/http.py | 19 +++++++++++++++++++ .../monitoring_modules/{load.py => load_ssh_linux.py} | 0 app/modules/monitoring_modules/memory_snmp_linux.py | 8 +++++++- .../{memory.py => memory_ssh_linux.py} | 0 app/modules/monitoring_modules/smtp.py | 1 + app/modules/monitoring_modules/swap_snmp_linux.py | 8 +++++++- .../monitoring_modules/{swap.py => swap_ssh_linux.py} | 0 ...ated_packages.py => updated_packages_ssh_linux.py} | 0 app/mum.py | 1 + 13 files changed, 45 insertions(+), 5 deletions(-) diff --git a/app/module_loader.py b/app/module_loader.py index 26a539e..fd6ac6e 100644 --- a/app/module_loader.py +++ b/app/module_loader.py @@ -271,8 +271,9 @@ class ModuleLoader: def run_one_monitoring_module(self, part_name, addr_host): """ - Instanciates and runs one monitoring_module of the package corresponding to - the operating system entered in parameters. + This function will first ask for the instanciation of the most prioritary connection. Then, for each module that + can check the requested part, we will see if the instanciated connection can be use for the check. If so, it + will run the 'check' function of the corresponding monitoring module with this connection. :param part_name: the name of the part to check :param addr_host: the IP address of the host """ diff --git a/app/modules/monitoring_modules/cpu.py b/app/modules/monitoring_modules/cpu_ssh_linux.py similarity index 100% rename from app/modules/monitoring_modules/cpu.py rename to app/modules/monitoring_modules/cpu_ssh_linux.py diff --git a/app/modules/monitoring_modules/disk_snmp_linux.py b/app/modules/monitoring_modules/disk_snmp_linux.py index 255b6df..1ebf706 100644 --- a/app/modules/monitoring_modules/disk_snmp_linux.py +++ b/app/modules/monitoring_modules/disk_snmp_linux.py @@ -12,5 +12,11 @@ def check(conn, mnce): total_space_on_disk = float(conn.exec_command(oid)) oid = ".1.3.6.1.4.1.2021.9.1.8.1" disk_used = float(conn.exec_command(oid)) - percent_disk_used = round((disk_used * 100) / total_space_on_disk, 2) + try: + percent_disk_used = round((disk_used * 100) / total_space_on_disk, 2) + except ZeroDivisionError: + exception_inst = getattr(mnce, "ModuleNotCompatibleException")( + part, conn.get_addr_host() + ) + raise exception_inst return percent_disk_used \ No newline at end of file diff --git a/app/modules/monitoring_modules/disk.py b/app/modules/monitoring_modules/disk_ssh_linux.py similarity index 100% rename from app/modules/monitoring_modules/disk.py rename to app/modules/monitoring_modules/disk_ssh_linux.py diff --git a/app/modules/monitoring_modules/http.py b/app/modules/monitoring_modules/http.py new file mode 100644 index 0000000..7e102e2 --- /dev/null +++ b/app/modules/monitoring_modules/http.py @@ -0,0 +1,19 @@ +__author__ = 'aguilbaud' + +import urllib2 + +compatible_os = ["all"] +block = "network" +part = "http" +unit = "bool" +connection = "" + + +def check(addr_host, http_port): + res_http_check = False + try: + res_http_check = urllib2.urlopen("http://" + addr_host + ":" + str(http_port)).getcode() == 200 + except urllib2.URLError: + pass + finally: + return res_http_check \ No newline at end of file diff --git a/app/modules/monitoring_modules/load.py b/app/modules/monitoring_modules/load_ssh_linux.py similarity index 100% rename from app/modules/monitoring_modules/load.py rename to app/modules/monitoring_modules/load_ssh_linux.py diff --git a/app/modules/monitoring_modules/memory_snmp_linux.py b/app/modules/monitoring_modules/memory_snmp_linux.py index 98b7e5c..f2a0e49 100644 --- a/app/modules/monitoring_modules/memory_snmp_linux.py +++ b/app/modules/monitoring_modules/memory_snmp_linux.py @@ -12,5 +12,11 @@ def check(conn, mnce): total_mem = float(conn.exec_command(oid)) oid = ".1.3.6.1.4.1.2021.4.6.0" mem_used = float(conn.exec_command(oid)) - percent_mem_used = round((mem_used * 100) / total_mem, 2) + try: + percent_mem_used = round((mem_used * 100) / total_mem, 2) + except ZeroDivisionError: + exception_inst = getattr(mnce, "ModuleNotCompatibleException")( + part, conn.get_addr_host() + ) + raise exception_inst return percent_mem_used \ No newline at end of file diff --git a/app/modules/monitoring_modules/memory.py b/app/modules/monitoring_modules/memory_ssh_linux.py similarity index 100% rename from app/modules/monitoring_modules/memory.py rename to app/modules/monitoring_modules/memory_ssh_linux.py diff --git a/app/modules/monitoring_modules/smtp.py b/app/modules/monitoring_modules/smtp.py index bba24ff..4eee977 100644 --- a/app/modules/monitoring_modules/smtp.py +++ b/app/modules/monitoring_modules/smtp.py @@ -8,6 +8,7 @@ part = "smtp" unit = "bool" connection = "" + def check(addr_host, smtp_port): res_smtp_check = True try: diff --git a/app/modules/monitoring_modules/swap_snmp_linux.py b/app/modules/monitoring_modules/swap_snmp_linux.py index 2e85f3d..8f8622c 100644 --- a/app/modules/monitoring_modules/swap_snmp_linux.py +++ b/app/modules/monitoring_modules/swap_snmp_linux.py @@ -12,5 +12,11 @@ def check(conn, mnce): total_swap = float(conn.exec_command(oid)) oid = ".1.3.6.1.4.1.2021.4.4.0" swap_used = total_swap - float(conn.exec_command(oid)) - percent_swap_used = round( (swap_used * 100) / total_swap, 2) + try: + percent_swap_used = round( (swap_used * 100) / total_swap, 2) + except ZeroDivisionError: + exception_inst = getattr(mnce, "ModuleNotCompatibleException")( + part, conn.get_addr_host() + ) + raise exception_inst return percent_swap_used \ No newline at end of file diff --git a/app/modules/monitoring_modules/swap.py b/app/modules/monitoring_modules/swap_ssh_linux.py similarity index 100% rename from app/modules/monitoring_modules/swap.py rename to app/modules/monitoring_modules/swap_ssh_linux.py diff --git a/app/modules/monitoring_modules/updated_packages.py b/app/modules/monitoring_modules/updated_packages_ssh_linux.py similarity index 100% rename from app/modules/monitoring_modules/updated_packages.py rename to app/modules/monitoring_modules/updated_packages_ssh_linux.py diff --git a/app/mum.py b/app/mum.py index a9bcd3e..5c77fe5 100755 --- a/app/mum.py +++ b/app/mum.py @@ -179,6 +179,7 @@ def receive(ws): elif code == "CHECK_NOW": # asekd from hostpage args = msg["CHECK_NOW"] ml.run_one_monitoring_module(args['mod_name'], args['addr_host']) + ws.send(json.dumps({"RES_INFO_HOST": ml.get_host_info(args['addr_host'])})) elif code == "GET_KEYS_LIST": # asked from hostpage, at the connection configuration ws.send(json.dumps({"KEYS_LIST": ml.get_public_keys_list()})) elif code == "TASK_LIST": -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
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 d2a9fd9c325ae5277d82afdc7854d0b76ab7c886 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Apr 22 14:02:03 2015 +0200 modules that don't need a connection launched separately (ping, http, smtp) + autoconf after scan also for these ones --- app/module_loader.py | 25 ++++++++++++++++++++----- app/modules/monitoring_modules/http.py | 19 ++++++++++++++----- app/modules/monitoring_modules/ping.py | 2 +- app/modules/monitoring_modules/smtp.py | 19 ++++++++++++++----- app/modules/storage_modules/shelve_db.py | 5 ++--- 5 files changed, 51 insertions(+), 19 deletions(-) diff --git a/app/module_loader.py b/app/module_loader.py index fd6ac6e..174ce9c 100644 --- a/app/module_loader.py +++ b/app/module_loader.py @@ -277,12 +277,27 @@ class ModuleLoader: :param part_name: the name of the part to check :param addr_host: the IP address of the host """ - if part_name == 'ping': - res_check = getattr(self.loaded_mod_moni['ping']['modules']['ping']['imported'], - 'check')(addr_host) - dict_notif = self.db.add_check(addr_host, part_name, res_check) - self.run_notification_modules(dict_notif) + if part_name in self.loaded_mod_moni[part_name]['modules'] and \ + getattr(self.loaded_mod_moni[part_name]['modules'][part_name]['imported'], 'connection') == "": + # the module which check this part doesn't need a connection + port_list = self.db.get_host_informations(addr_host)['detected']['nmap']['openports'] + try: + res_check = getattr(self.loaded_mod_moni[part_name]['modules'][part_name]['imported'], + 'check')(addr_host, + port_list, + modules.CommandNotFoundException) + dict_notif = self.db.add_check(addr_host, part_name, res_check) + self.run_notification_modules(dict_notif) + except modules.CommandNotFoundException.CommandNotFoundException: + print "No port " + part_name + " on " + addr_host + \ + ". This part checking have been deactivated." + process_monitoring.remove_to_waiting_list(addr_host, part_name) + dict_deactivation_request = {} + dict_deactivation_request['addr_host'] = addr_host + dict_deactivation_request['activated'] = {part_name: False} + self.db.config_mod_activation(dict_deactivation_request) else: + # to check this part, it is necessary to create a connection with the host... # getting all availiable connections for this part to check compatible_conn = self.loaded_mod_moni[part_name]['compatible_conn'] conf_conn = self.db.get_conf_conn(addr_host) diff --git a/app/modules/monitoring_modules/http.py b/app/modules/monitoring_modules/http.py index 7e102e2..56d3327 100644 --- a/app/modules/monitoring_modules/http.py +++ b/app/modules/monitoring_modules/http.py @@ -9,11 +9,20 @@ unit = "bool" connection = "" -def check(addr_host, http_port): +def check(addr_host, port_list, cnfe): res_http_check = False + http_port_found = False try: - res_http_check = urllib2.urlopen("http://" + addr_host + ":" + str(http_port)).getcode() == 200 + for i in range(len(port_list)): + if port_list[i]['portname'] == part: + http_port_found = True + res_http_check = urllib2.urlopen("http://" + addr_host + ":" + str(port_list[i]['portid']) + ).getcode() == 200 + if not http_port_found: + exception_inst = getattr(cnfe, "CommandNotFoundException")( + part, addr_host + ) + raise exception_inst + return res_http_check except urllib2.URLError: - pass - finally: - return res_http_check \ No newline at end of file + res_http_check = False \ No newline at end of file diff --git a/app/modules/monitoring_modules/ping.py b/app/modules/monitoring_modules/ping.py index a3da3c1..c433507 100644 --- a/app/modules/monitoring_modules/ping.py +++ b/app/modules/monitoring_modules/ping.py @@ -10,7 +10,7 @@ unit = "bool" connection = "" -def check(addr_host): +def check(addr_host, port_list, cnfe): res_check = False try: child = pexpect.spawn('ping '+ addr_host + ' -c 1') diff --git a/app/modules/monitoring_modules/smtp.py b/app/modules/monitoring_modules/smtp.py index 4eee977..f21ae0a 100644 --- a/app/modules/monitoring_modules/smtp.py +++ b/app/modules/monitoring_modules/smtp.py @@ -9,11 +9,20 @@ unit = "bool" connection = "" -def check(addr_host, smtp_port): +def check(addr_host, port_list, cnfe): res_smtp_check = True + smtp_port_found = False try: - s = smtplib.SMTP(addr_host, smtp_port) + for i in range(len(port_list)): + if port_list[i]['portname'] == part: + smtp_port_found = True + s = smtplib.SMTP(addr_host, str(port_list[i]['portid'])) + s.quit() + if not smtp_port_found: + exception_inst = getattr(cnfe, "CommandNotFoundException")( + part, addr_host + ) + raise exception_inst + return res_smtp_check except Exception: - res_smtp_check = False - finally: - return res_smtp_check \ No newline at end of file + res_smtp_check = False \ 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 290d35d..d32612a 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -193,6 +193,7 @@ class shelve_db: self.db["hosts"][addr_host]["monitoring"] = {} # Create structure for global status of host self.db["hosts"][addr_host]["status"] = {} + self.db["hosts"][addr_host]["status"]["state"] = "" # Create structure for archiving data self.db["hosts"][addr_host]["archive"] = {} except Exception: @@ -414,9 +415,7 @@ class shelve_db: res['hostname'] = json.loads(self.db['hosts'][addr_host]['detected']['nmap'])['hostname'] else: res['hostname'] = '' - res['monitoring'] = {} - for mod in self.db['hosts'][addr_host]['monitoring']: - res['monitoring'][mod] = self.db['hosts'][addr_host]['monitoring'][mod] + res['monitoring'] = self.db['hosts'][addr_host]['monitoring'] res['detected'] = {} for mod in self.db['hosts'][addr_host]['detected']: res['detected'][mod] = json.loads(self.db['hosts'][addr_host]['detected'][mod]) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm