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 1fbeb70ae972d23e36645b963f594debefb61043 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Mon Apr 27 11:25:31 2015 +0200 commented snmp modules + smtp module do helo request using smtplib --- app/modules/monitoring_modules/15_min_load_snmp_linux.py | 8 ++++++-- app/modules/monitoring_modules/cpu_snmp_linux.py | 12 +++++++----- app/modules/monitoring_modules/disk_snmp_linux.py | 10 ++++++---- app/modules/monitoring_modules/http.py | 5 ++++- app/modules/monitoring_modules/memory_snmp_linux.py | 10 ++++++---- app/modules/monitoring_modules/smtp.py | 13 ++++++++++--- app/modules/monitoring_modules/swap_snmp_linux.py | 10 ++++++---- 7 files changed, 45 insertions(+), 23 deletions(-) diff --git a/app/modules/monitoring_modules/15_min_load_snmp_linux.py b/app/modules/monitoring_modules/15_min_load_snmp_linux.py index 00ab092..6334708 100644 --- a/app/modules/monitoring_modules/15_min_load_snmp_linux.py +++ b/app/modules/monitoring_modules/15_min_load_snmp_linux.py @@ -9,6 +9,10 @@ connection = "snmp" def check(conn, mnce): - oid = ".1.3.6.1.4.1.2021.10.1.3.3" - load = float(conn.exec_command(oid)) + # http://www.oid-info.com/get/1.3.6.1.4.1.2021.10.1.3 (.X) + # X = 1 : 5 min load + # X = 2 : 10 min load + # X = 3 : 15 min load + oid_15_min_load = ".1.3.6.1.4.1.2021.10.1.3.3" + load = float(conn.exec_command(oid_15_min_load)) return load \ No newline at end of file diff --git a/app/modules/monitoring_modules/cpu_snmp_linux.py b/app/modules/monitoring_modules/cpu_snmp_linux.py index fad9f05..fa395e3 100644 --- a/app/modules/monitoring_modules/cpu_snmp_linux.py +++ b/app/modules/monitoring_modules/cpu_snmp_linux.py @@ -10,11 +10,13 @@ connection = "snmp" def check(conn, mnce): """ - Check the greatest between the user and system CPU charge + Returns the greatest between the user and system CPU charge """ - oid = ".1.3.6.1.4.1.2021.11.9.0" - user_cpu_charge = int(conn.exec_command(oid)) - oid = ".1.3.6.1.4.1.2021.11.10.0" - system_cpu_charge = int(conn.exec_command(oid)) + # http://www.oid-info.com/get/1.3.6.1.4.1.2021.11.9.0 + oid_user_cpu_charge = ".1.3.6.1.4.1.2021.11.9.0" + user_cpu_charge = int(conn.exec_command(oid_user_cpu_charge)) + # http://www.oid-info.com/get/1.3.6.1.4.1.2021.11.10.0 + oid_system_cpu_charge = ".1.3.6.1.4.1.2021.11.10.0" + system_cpu_charge = int(conn.exec_command(oid_system_cpu_charge)) res_cpu = max(user_cpu_charge, system_cpu_charge) return res_cpu \ No newline at end of file diff --git a/app/modules/monitoring_modules/disk_snmp_linux.py b/app/modules/monitoring_modules/disk_snmp_linux.py index 1ebf706..c18d153 100644 --- a/app/modules/monitoring_modules/disk_snmp_linux.py +++ b/app/modules/monitoring_modules/disk_snmp_linux.py @@ -8,10 +8,12 @@ connection = "snmp" def check(conn, mnce): - oid = ".1.3.6.1.4.1.2021.9.1.7.1" - 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)) + # http://www.oid-info.com/get/1.3.6.1.4.1.2021.9.1.7.1 + oid_available_space = ".1.3.6.1.4.1.2021.9.1.7.1" + total_space_on_disk = float(conn.exec_command(oid_available_space)) + # http://www.oid-info.com/get/1.3.6.1.4.1.2021.9.1.8.1 + oid_used_space = ".1.3.6.1.4.1.2021.9.1.8.1" + disk_used = float(conn.exec_command(oid_used_space)) try: percent_disk_used = round((disk_used * 100) / total_space_on_disk, 2) except ZeroDivisionError: diff --git a/app/modules/monitoring_modules/http.py b/app/modules/monitoring_modules/http.py index 8ba058f..1475b31 100644 --- a/app/modules/monitoring_modules/http.py +++ b/app/modules/monitoring_modules/http.py @@ -14,17 +14,20 @@ def check(addr_host, port_list, cnfe): http_port_found = False try: for i in range(len(port_list)): + # for each http port detected for this host if port_list[i]['portname'] == part: http_port_found = True + # the result of the check is true if urlopen returns the http code 200 res_http_check = urllib2.urlopen("http://" + addr_host + ":" + str(port_list[i]['portid']), None, 10 ).getcode() == 200 if not http_port_found: + # if there is no http port detected for this host exception_inst = getattr(cnfe, "CommandNotFoundException")( part, addr_host ) raise exception_inst return res_http_check - except urllib2.URLError: + except Exception: return False \ No newline at end of file diff --git a/app/modules/monitoring_modules/memory_snmp_linux.py b/app/modules/monitoring_modules/memory_snmp_linux.py index f2a0e49..fbbc95a 100644 --- a/app/modules/monitoring_modules/memory_snmp_linux.py +++ b/app/modules/monitoring_modules/memory_snmp_linux.py @@ -8,10 +8,12 @@ connection = "snmp" def check(conn, mnce): - oid = ".1.3.6.1.4.1.2021.4.5.0" - 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)) + # http://www.oid-info.com/get/1.3.6.1.4.1.2021.4.5.0 + oid_total_ram_avaliable = ".1.3.6.1.4.1.2021.4.5.0" + total_mem = float(conn.exec_command(oid_total_ram_avaliable)) + # http://www.oid-info.com/get/1.3.6.1.4.1.2021.4.6.0 + oid_total_ram_used = ".1.3.6.1.4.1.2021.4.6.0" + mem_used = float(conn.exec_command(oid_total_ram_used)) try: percent_mem_used = round((mem_used * 100) / total_mem, 2) except ZeroDivisionError: diff --git a/app/modules/monitoring_modules/smtp.py b/app/modules/monitoring_modules/smtp.py index 253d5bc..531f13e 100644 --- a/app/modules/monitoring_modules/smtp.py +++ b/app/modules/monitoring_modules/smtp.py @@ -1,6 +1,6 @@ __author__ = 'aguilbaud' -import telnetlib +import smtplib compatible_os = ["all"] block = "network" @@ -10,14 +10,21 @@ connection = "" def check(addr_host, port_list, cnfe): - res_smtp_check = True + res_smtp_check = False smtp_port_found = False try: for i in range(len(port_list)): + # for each smtp port detected for this host if port_list[i]['portname'] == part: smtp_port_found = True - res_smtp_check = telnetlib.Telnet(addr_host, int(port_list[i]['portid']), 10).read_some() != "" + # try to connect to this port, with a timeout of 10 seconds + smtp_conn_inst = smtplib.SMTP(addr_host, int(port_list[i]['portid']), 10) + # send a HELO request and should return a tuple with 250 as first member if OK + res_smtp_check = smtp_conn_inst.helo()[0] == 250 + # close the connection when finished + smtp_conn_inst.quit() if not smtp_port_found: + # if there is no smtp port detected for this host exception_inst = getattr(cnfe, "CommandNotFoundException")( part, addr_host ) diff --git a/app/modules/monitoring_modules/swap_snmp_linux.py b/app/modules/monitoring_modules/swap_snmp_linux.py index 8f8622c..c7940ec 100644 --- a/app/modules/monitoring_modules/swap_snmp_linux.py +++ b/app/modules/monitoring_modules/swap_snmp_linux.py @@ -8,10 +8,12 @@ connection = "snmp" def check(conn, mnce): - oid = ".1.3.6.1.4.1.2021.4.3.0" - 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)) + # http://www.oid-info.com/get/1.3.6.1.4.1.2021.4.3.0 + oid_total_swap_size = ".1.3.6.1.4.1.2021.4.3.0" + total_swap = float(conn.exec_command(oid_total_swap_size)) + # http://www.oid-info.com/get/1.3.6.1.4.1.2021.4.4.0 + oid_avaliable_swap_space = ".1.3.6.1.4.1.2021.4.4.0" + swap_used = total_swap - float(conn.exec_command(oid_avaliable_swap_space)) try: percent_swap_used = round( (swap_used * 100) / total_swap, 2) except ZeroDivisionError: -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.