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