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 9d8f7dd70ae45432e1b0935f7a60d6b22c130cbc Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Fri Feb 20 18:25:54 2015 +0100 memory module added --- app/module_loader.py | 2 +- app/modules/connection_modules/ssh.py | 30 +--------------------- app/modules/monitoring_modules/unix/__init__.py | 5 ++-- app/modules/monitoring_modules/unix/memory.py | 22 ++++++++++++++++ .../monitoring_modules/unix/updated_packages.py | 10 +------- app/modules/storage_modules/shelve_db.py | 4 +-- 6 files changed, 30 insertions(+), 43 deletions(-) diff --git a/app/module_loader.py b/app/module_loader.py index d084005..8ea04d2 100644 --- a/app/module_loader.py +++ b/app/module_loader.py @@ -104,7 +104,7 @@ def get_info_mod_monitoring(os): } """ __import__("modules.monitoring_modules." + os) - pack_mod_os = __import__("modules.monitoring_modules." + os, fromlist=modules.monitoring_modules.__all__) + pack_mod_os = __import__("modules.monitoring_modules." + os, fromlist=modules.monitoring_modules.__all__) return pack_mod_os.info_mod diff --git a/app/modules/connection_modules/ssh.py b/app/modules/connection_modules/ssh.py index 9befed0..0d799b9 100644 --- a/app/modules/connection_modules/ssh.py +++ b/app/modules/connection_modules/ssh.py @@ -19,32 +19,4 @@ class ssh: return res def disconnect(self): - self.ssh.close() - - - ''' - # Informations materielles globales - def detect_hardware(ssh): - cmd = "lshw -json" - stdin, stdout, stderr = ssh.exec_command(cmd) - res = "" - for line in stdout.read().splitlines(): - res += line - res_json = json.loads(res) - # TODO Traitement du resultat pour garder l'essentiel... - return res_json - - - - - # dependant de la langue du systeme ? - def detect_non_updated_packages(ssh): - cmd = "apt-get upgrade -s" - stdin, stdout, stderr = ssh.exec_command(cmd) - res = stdout.read() - tab_res = res.split(':') - if len(tab_res) == 2: - return json.dumps({'non_updated_packages': False}) - else: - return json.dumps({'non_updated_packages': True}) - ''' \ No newline at end of file + self.ssh.close() \ No newline at end of file diff --git a/app/modules/monitoring_modules/unix/__init__.py b/app/modules/monitoring_modules/unix/__init__.py index ac9e130..8efe043 100644 --- a/app/modules/monitoring_modules/unix/__init__.py +++ b/app/modules/monitoring_modules/unix/__init__.py @@ -1,5 +1,6 @@ __author__ = 'aguilbaud' -__all__=['updated_packages'] +__all__=['updated_packages', 'memory'] info_mod = { - 'updated_packages': {'block': 'software', 'unit': 'bool'} + 'updated_packages': {'block': 'software', 'unit': 'bool'}, + 'memory': {'block': 'hardware', 'unit': 'kB'} } \ No newline at end of file diff --git a/app/modules/monitoring_modules/unix/memory.py b/app/modules/monitoring_modules/unix/memory.py new file mode 100644 index 0000000..2b36cf5 --- /dev/null +++ b/app/modules/monitoring_modules/unix/memory.py @@ -0,0 +1,22 @@ +__author__ = 'aguilbaud' +import json +import re + +class memory: + def __init__(self, conn, db): + self.conn = conn + self.db = db + + def check(self): + cmd = "cat /proc/meminfo" + stdout = self.conn.exec_command(cmd) + memfree = 0 + memtotal = 0 + for line in stdout.splitlines(): + tab_res = line.split(':') + if(tab_res[0]) == 'MemTotal': + memtotal = re.sub("[^0-9]", "", tab_res[1]) + elif(tab_res[0]) == 'MemFree': + memfree = re.sub("[^0-9]", "", tab_res[1]) + res_check = json.dumps({"memory": (int(memfree) * 100) / int(memtotal)}) + self.db.add_check(self.conn.get_addr_host(), "memory", res_check) \ No newline at end of file diff --git a/app/modules/monitoring_modules/unix/updated_packages.py b/app/modules/monitoring_modules/unix/updated_packages.py index 9d97802..a0642fc 100644 --- a/app/modules/monitoring_modules/unix/updated_packages.py +++ b/app/modules/monitoring_modules/unix/updated_packages.py @@ -6,8 +6,6 @@ class updated_packages: def __init__(self, conn, db): self.conn = conn self.db = db - self.block = "software" - self.unit = "bool" def check(self): cmd = "apt-get upgrade -s" @@ -17,10 +15,4 @@ class updated_packages: res_check = json.dumps({'non_updated_packages': False}) else: res_check = json.dumps({'non_updated_packages': True}) - self.db.add_check(self.conn.get_addr_host(), "updated_packages", res_check) - - def get_block(self): - return self.block - - def get_unit(self): - return self.unit \ No newline at end of file + self.db.add_check(self.conn.get_addr_host(), "updated_packages", res_check) \ 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 d04297c..b3c2d7e 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -287,8 +287,8 @@ class shelve_db: self.db['global_conf'][os][mod]['minor_limit'] = 95 self.db['global_conf'][os][mod]['major_limit'] = 100 elif unit == 'bool': - self.db['global_conf'][os][mod]['minor_limit'] = False - self.db['global_conf'][os][mod]['major_limit'] = True + self.db['global_conf'][os][mod]['minor_limit'] = True + self.db['global_conf'][os][mod]['major_limit'] = False else: self.db['global_conf'][os][mod]['minor_limit'] = 8 self.db['global_conf'][os][mod]['major_limit'] = 10 -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.