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 e13c42cfe4304fdb99a09ad62f5c02d051dff02d Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Fri Apr 3 16:16:50 2015 +0200 swap monitoring module added + monitoring isntructions removed from process list if execution failed --- app/module_loader.py | 3 +++ app/modules/monitoring_modules/swap.py | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/app/module_loader.py b/app/module_loader.py index b50d413..2643b3f 100644 --- a/app/module_loader.py +++ b/app/module_loader.py @@ -98,6 +98,7 @@ class ModuleLoader: modules.CommandNotFoundException) else: print "Error: no connection have been configured yet" + process_monitoring.remove_to_waiting_list(addr_host, None) return mod_inst def test_connection(self, addr_host, conn_mod_name): @@ -221,8 +222,10 @@ class ModuleLoader: self.run_notification_modules(dict_notif) except modules.ModuleNotCompatibleException.ModuleNotCompatibleException as mnce: print mnce.__str__() + process_monitoring.remove_to_waiting_list(addr_host, mod_name) except modules.CommandNotFoundException.CommandNotFoundException as cnfe: print cnfe.__str__() + process_monitoring.remove_to_waiting_list(addr_host, mod_name) def get_monitoring_modules_list(self): """ diff --git a/app/modules/monitoring_modules/swap.py b/app/modules/monitoring_modules/swap.py new file mode 100644 index 0000000..0c64d89 --- /dev/null +++ b/app/modules/monitoring_modules/swap.py @@ -0,0 +1,26 @@ +# -*- coding: utf8 -*- +__author__ = 'aguilbaud' + +compatible_os = ['linux', 'unix'] +block = "hardware" +unit = "%" + + +def check(conn, db, mnce): + cmd = "free -m" + stdout = conn.exec_command(cmd) + swap_total = 0 + swap_used = 0 + for line in stdout.splitlines(): + fields = line.split() + if fields[0] == 'Swap:': + swap_total = fields[1] + swap_used = fields[2] + try: + res_swap = (int(swap_used) * 100) / int(swap_total) + except ZeroDivisionError: + exception_inst = getattr(mnce, "ModuleNotCompatibleException")( + "swap", conn.get_addr_host() + ) + raise exception_inst + return db.add_check(conn.get_addr_host(), 'swap', res_swap) \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.