branch develop updated (fd2a1c1 -> d1d7858)
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 fd2a1c1 add kernel snmp detection new 159f40f param attribute loaded from modules; string and int values can be configured on hostpage. new df5cb6c removed LANG=C on ssh commands (does not work), must find another way to use env variables with Paramiko new 45e342b "default" attribute loaded from modules and can overwrite the values from the inital configuration new d1d7858 Merge branch 'develop' of https://git.chorem.org/mum into develop The 4 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 d1d785850303557645ecdf44bc4a34a7ec41287b Merge: 45e342b fd2a1c1 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Jul 8 17:34:47 2015 +0200 Merge branch 'develop' of https://git.chorem.org/mum into develop commit 45e342bd51c010cbd98ade15b643a4312c2c2c84 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Jul 8 17:26:45 2015 +0200 "default" attribute loaded from modules and can overwrite the values from the inital configuration commit df5cb6c2e6ebad6ab980efb410b71f9ecd41549f Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Jul 8 16:49:15 2015 +0200 removed LANG=C on ssh commands (does not work), must find another way to use env variables with Paramiko commit 159f40f0e12016c1e799f4dc3d21dd2b03367485 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Jul 8 16:47:50 2015 +0200 param attribute loaded from modules; string and int values can be configured on hostpage. Summary of changes: app/module_loader.py | 146 ++++++++++++--------- app/modules/monitoring_modules/cpu_ssh_linux.py | 2 +- app/modules/monitoring_modules/disk_ssh_linux.py | 2 +- app/modules/monitoring_modules/ping.py | 6 +- app/modules/monitoring_modules/swap_ssh_linux.py | 2 +- .../updated_packages_ssh_linux.py | 2 +- app/modules/storage_modules/shelve_db.py | 12 +- static/js/controllers/hostPageCtrl.js | 27 +++- views/hostpage.html | 29 +++- 9 files changed, 154 insertions(+), 74 deletions(-) -- 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 159f40f0e12016c1e799f4dc3d21dd2b03367485 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Jul 8 16:47:50 2015 +0200 param attribute loaded from modules; string and int values can be configured on hostpage. --- app/module_loader.py | 138 ++++++++++++++++++------------- app/modules/monitoring_modules/ping.py | 6 +- app/modules/storage_modules/shelve_db.py | 7 +- static/js/controllers/hostPageCtrl.js | 27 +++++- views/hostpage.html | 29 +++++-- 5 files changed, 137 insertions(+), 70 deletions(-) diff --git a/app/module_loader.py b/app/module_loader.py index e6b0234..797f494 100644 --- a/app/module_loader.py +++ b/app/module_loader.py @@ -296,6 +296,14 @@ class ModuleLoader: self.loaded_mod_moni[part]['compatible_conn'].append(getattr(loaded_mod, 'connection')) self.loaded_mod_moni[part]['compatible_conn'] = \ list(set(self.loaded_mod_moni[part]['compatible_conn'])) + try: + self.loaded_mod_moni[part]['param'] = getattr(loaded_mod, 'param') + except AttributeError: + self.loaded_mod_moni[part]['param'] = {} + try: + self.loaded_mod_moni[part]['default'] = getattr(loaded_mod, 'default') + except AttributeError: + self.loaded_mod_moni[part]['default'] = {} except AttributeError: self.logger.warning("Error : internal monitoring module " + mod_name + " could not have been loaded.") self.logger.debug(traceback.format_exc()) @@ -343,65 +351,75 @@ class ModuleLoader: :param part_name: the name of the part to check :param addr_host: the IP address of the host """ - 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_nmap_result(addr_host)['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: - msg = "No port " + part_name + " on " + addr_host + ". This part checking have been deactivated." - self.logger.warning(msg) - self.wsc.notify_module_deactivation(msg) - 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 - conf_conn = self.db.get_conf_conn(addr_host) - check_done = False - i = 0 - while i < len(conf_conn) and not check_done: - # for each connection that have been configurated for this host (by priority) - for mod in self.loaded_mod_moni[part_name]['modules']: - # for each monitoring module, being from this part, activated for this host - loaded_mod = self.loaded_mod_moni[part_name]['modules'][mod]['imported'] - if getattr(loaded_mod, 'connection') == conf_conn[i]['conn_mod_name']: - subpart_list = self.db.get_subpart(addr_host, part_name) - # if this monitoring module is compatible for the current connection - try: - conn_inst = self.create_connection(addr_host, conf_conn[i]) - res_check = getattr(loaded_mod, - 'check')(conn_inst, - modules.ModuleNotCompatibleException, - subpart_list) - dict_notif = self.db.add_check(conn_inst.get_addr_host(), part_name, res_check) - self.run_notification_modules(dict_notif) - check_done = True - except Exception: - self.logger.warning("The connection could not have been established with " + conf_conn[i]['conn_mod_name']\ - + " on " + addr_host) - self.logger.debug(traceback.format_exc()) - self.logger.warning("Now trying on next avaliable connection...") - i += 1 - if not check_done: - msg = "No necessary connection have been properly configured for " + part_name + " on " + addr_host + \ - ". Therefore it has been deactivated." - self.logger.warning(msg) - self.wsc.notify_module_deactivation(msg) - 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) + try: + 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_nmap_result(addr_host)['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: + msg = "No port " + part_name + " on " + addr_host + ". This part checking have been deactivated." + self.logger.warning(msg) + self.wsc.notify_module_deactivation(msg) + 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 + conf_conn = self.db.get_conf_conn(addr_host) + check_done = False + i = 0 + while i < len(conf_conn) and not check_done: + # for each connection that have been configurated for this host (by priority) + for mod in self.loaded_mod_moni[part_name]['modules']: + # for each monitoring module, being from this part, activated for this host + loaded_mod = self.loaded_mod_moni[part_name]['modules'][mod]['imported'] + if getattr(loaded_mod, 'connection') == conf_conn[i]['conn_mod_name']: + subpart_list = self.db.get_subpart(addr_host, part_name) + # if this monitoring module is compatible for the current connection + try: + conn_inst = self.create_connection(addr_host, conf_conn[i]) + res_check = getattr(loaded_mod, + 'check')(conn_inst, + modules.ModuleNotCompatibleException, + subpart_list) + dict_notif = self.db.add_check(conn_inst.get_addr_host(), part_name, res_check) + self.run_notification_modules(dict_notif) + check_done = True + except Exception: + self.logger.warning("The connection could not have been established with " + conf_conn[i]['conn_mod_name']\ + + " on " + addr_host) + self.logger.debug(traceback.format_exc()) + self.logger.warning("Now trying on next avaliable connection...") + i += 1 + if not check_done: + msg = "No necessary connection have been properly configured for " + part_name + " on " + addr_host + \ + ". Therefore it has been deactivated." + self.logger.warning(msg) + self.wsc.notify_module_deactivation(msg) + 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) + except KeyError: + msg = "The module " + part_name + " has not been loaded. Desactivation for " + addr_host + self.logger.warning(msg) + self.wsc.notify_module_deactivation(msg) + 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) def get_monitoring_modules_list(self): """ @@ -442,6 +460,8 @@ class ModuleLoader: res[part] = {} res[part]['compatible_os'] = self.loaded_mod_moni[part]['compatible_os'] res[part]['compatible_conn'] = self.loaded_mod_moni[part]['compatible_conn'] + res[part]['default'] = self.loaded_mod_moni[part]['default'] + res[part]['param'] = self.loaded_mod_moni[part]['param'] mod_sample = self.loaded_mod_moni[part]['modules'].keys()[0] loaded_mod_sample = self.loaded_mod_moni[part]['modules'][mod_sample]['imported'] res[part]['unit'] = getattr(loaded_mod_sample, 'unit') diff --git a/app/modules/monitoring_modules/ping.py b/app/modules/monitoring_modules/ping.py index f00d625..a21d714 100644 --- a/app/modules/monitoring_modules/ping.py +++ b/app/modules/monitoring_modules/ping.py @@ -20,7 +20,6 @@ __author__ = 'aguilbaud' import pexpect - compatible_os = ["all"] block = "network" part = "Ping" @@ -28,11 +27,14 @@ name = part unit = "bool" connection = "" +default = { + "check_frequency": 420 +} def check(addr_host, port_list, cnfe): res_check = False try: - child = pexpect.spawn('ping '+ addr_host + ' -c 1') + child = pexpect.spawn('ping ' + addr_host + ' -c 1', env={'LANG': 'C'}) while child.isalive(): child.expect('packets transmitted, ') child.expect(' received') diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index 8d2e75b..43cb394 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -187,8 +187,8 @@ class shelve_db: else: mod_conf['minor_limit'] = 8 mod_conf['major_limit'] = 10 - if 'param' in loaded_mod_moni: - mod_conf['param'] = loaded_mod_moni['param'] + if 'param' in loaded_mod_moni[mod]: + mod_conf['param'] = loaded_mod_moni[mod]['param'] mod_conf['subscribers'] = {} self.db['global_conf'][mod] = mod_conf # removing entries of modules that are no loaded anymore @@ -851,6 +851,8 @@ class shelve_db: res['freq'] = self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['check_frequency'] for period in ['min', 'hour', 'day', 'week', 'month', 'year']: res['nb_' + period] = self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['nb_' + period] + if 'param' in self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]: + res['param'] = self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['param'] except Exception: self.logger.error(traceback.format_exc()) finally: @@ -881,6 +883,7 @@ class shelve_db: self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['nb_' + period] = None else: self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['nb_' + period] = args['nb_' + period] + self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['param'] = args['param'] except Exception: self.logger.error(traceback.format_exc()) finally: diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index 295dfb9..ca2a81e 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -386,14 +386,20 @@ mumApp.controller('ModalConfInstanceCtrl', function ($scope, $rootScope, $modalI $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_conf_mod', 'args': conf_args}})); - $scope.items = {} /* { + $scope.items = {}; /* { 'unit' : val, // the unit of the value 'minor_limit' : val, 'major_limit' : val, - 'freq' : val + 'freq' : val, + 'param': {param_name: + {'type': str, 'doc': str, 'value': val}, + ... + } } */ + $scope.param_struct = {}; + // init fields $scope.freq_days = 0; $scope.freq_hours = 0; @@ -442,10 +448,25 @@ mumApp.controller('ModalConfInstanceCtrl', function ($scope, $rootScope, $modalI $scope.arch_week = args.res.nb_week; $scope.arch_month = args.res.nb_month; $scope.arch_year = args.res.nb_year; + update_param_struct(); }, 0); } }); + var update_param_struct = function (){ + /* + Formats the custom parameters to have the type as a key. Permits to generate the form with ng-repeat. + */ + for (var param_name in $scope.items.param){ + var dict_param = $scope.items.param[param_name]; + dict_param.param_name = param_name; + if (!$scope.param_struct.hasOwnProperty(dict_param.type)){ + $scope.param_struct[dict_param.type] = []; + } + $scope.param_struct[dict_param.type].push(dict_param); + } + }; + // after validation $scope.ok = function () { var args = {}; @@ -471,6 +492,8 @@ mumApp.controller('ModalConfInstanceCtrl', function ($scope, $rootScope, $modalI args.nb_month = $scope.arch_month; args.nb_year = $scope.arch_year; + args.param = $scope.items.param; + $rootScope.$broadcast("sendViaWs", JSON.stringify({"SET_CONF_MOD": args})); $modalInstance.close(); diff --git a/views/hostpage.html b/views/hostpage.html index b67b034..eb49af9 100644 --- a/views/hostpage.html +++ b/views/hostpage.html @@ -278,7 +278,8 @@ </div> <div class="modal-body"> - + {{items}}<br/><br/><br/> + {{param_struct}} <form> <div class="form-group"> <label for="arch">Archives to keep (in check numbers). Keep empty for no limit.</label> @@ -381,6 +382,24 @@ </div> </form> + <h3>Custom parameters</h3> + + <div class="row" + ng-repeat="dict_param in param_struct.string"> + <p>{{items.param[dict_param.param_name].doc}}</p> + <div class="col-xs-3"> + <input type="text" ng-model="items.param[dict_param.param_name].value"/> + </div> + </div> + + <div class="row" + ng-repeat="dict_param in param_struct.int"> + <p>{{items.param[dict_param.param_name].doc}}</p> + <div class="col-xs-3"> + <input type="number" ng-model="items.param[dict_param.param_name].value"/> + </div> + </div> + </div> <div class="modal-footer"> @@ -475,7 +494,7 @@ Upload a new key: <span ng-bind="item.file.name"></span><br/> <button ng-click="item.upload(item, '\keys')">upload</button> </li> - </ul>--> + </ul> <div class="row"> <input type="radio" value="login"> Login/Password @@ -500,9 +519,9 @@ ng-model="private_key" ng-options="key as key for key in keys_list"></select> </div> - </div> + </div>--> + - <!-- <div class="row" ng-show="show_form('private_key')"> <div class="col-xs-3"> <label for="private_key">Select a private key</label> @@ -548,7 +567,7 @@ <label for="domain">Domain</label> <input type="text" id="domain" ng-model="username"/> </div> - </div>--> + </div> </div> <div class="modal-footer"> -- 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 df5cb6c2e6ebad6ab980efb410b71f9ecd41549f Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Jul 8 16:49:15 2015 +0200 removed LANG=C on ssh commands (does not work), must find another way to use env variables with Paramiko --- app/modules/monitoring_modules/cpu_ssh_linux.py | 2 +- app/modules/monitoring_modules/disk_ssh_linux.py | 2 +- app/modules/monitoring_modules/swap_ssh_linux.py | 2 +- app/modules/monitoring_modules/updated_packages_ssh_linux.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/modules/monitoring_modules/cpu_ssh_linux.py b/app/modules/monitoring_modules/cpu_ssh_linux.py index 6382064..71e169a 100644 --- a/app/modules/monitoring_modules/cpu_ssh_linux.py +++ b/app/modules/monitoring_modules/cpu_ssh_linux.py @@ -30,7 +30,7 @@ def check(conn, mnce, subparts): """ Returns the greatest between the user and system CPU charge """ - cmd = "LANG=C top -b -n 1" + cmd = "top -b -n 1" stdout = conn.exec_command(cmd) # output example: diff --git a/app/modules/monitoring_modules/disk_ssh_linux.py b/app/modules/monitoring_modules/disk_ssh_linux.py index df02802..74895c6 100644 --- a/app/modules/monitoring_modules/disk_ssh_linux.py +++ b/app/modules/monitoring_modules/disk_ssh_linux.py @@ -30,7 +30,7 @@ connection = "ssh" def check(conn, mnce, subparts): - cmd = "LANG=C df -h" + cmd = "df -h" stdout = conn.exec_command(cmd) # output example: diff --git a/app/modules/monitoring_modules/swap_ssh_linux.py b/app/modules/monitoring_modules/swap_ssh_linux.py index 6330b81..f0db360 100644 --- a/app/modules/monitoring_modules/swap_ssh_linux.py +++ b/app/modules/monitoring_modules/swap_ssh_linux.py @@ -27,7 +27,7 @@ connection = "ssh" def check(conn, mnce, subparts): - cmd = "LANG=C free -m" + cmd = "free -m" stdout = conn.exec_command(cmd) # output example: diff --git a/app/modules/monitoring_modules/updated_packages_ssh_linux.py b/app/modules/monitoring_modules/updated_packages_ssh_linux.py index 359fe22..db75af0 100644 --- a/app/modules/monitoring_modules/updated_packages_ssh_linux.py +++ b/app/modules/monitoring_modules/updated_packages_ssh_linux.py @@ -30,7 +30,7 @@ connection = "ssh" def check(conn, mnce, subparts): - cmd = "LANG=C apt-get upgrade -s" + cmd = "apt-get upgrade -s" stdout = conn.exec_command(cmd) # Output example: -- 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 45e342bd51c010cbd98ade15b643a4312c2c2c84 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Jul 8 17:26:45 2015 +0200 "default" attribute loaded from modules and can overwrite the values from the inital configuration --- app/module_loader.py | 8 ++++++++ app/modules/storage_modules/shelve_db.py | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/app/module_loader.py b/app/module_loader.py index 797f494..1ceeb73 100644 --- a/app/module_loader.py +++ b/app/module_loader.py @@ -339,6 +339,14 @@ class ModuleLoader: self.loaded_mod_moni[part]['compatible_conn'].append(getattr(loaded_mod, 'connection')) self.loaded_mod_moni[part]['compatible_conn'] = \ list(set(self.loaded_mod_moni[part]['compatible_conn'])) + try: + self.loaded_mod_moni[part]['param'] = getattr(loaded_mod, 'param') + except AttributeError: + self.loaded_mod_moni[part]['param'] = {} + try: + self.loaded_mod_moni[part]['default'] = getattr(loaded_mod, 'default') + except AttributeError: + self.loaded_mod_moni[part]['default'] = {} except AttributeError: self.logger.warning("Error : external monitoring module " + mod_name + " could not have been loaded.") self.logger.debug(traceback.format_exc()) diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index 43cb394..ab78bf8 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -189,6 +189,8 @@ class shelve_db: mod_conf['major_limit'] = 10 if 'param' in loaded_mod_moni[mod]: mod_conf['param'] = loaded_mod_moni[mod]['param'] + for default_val in loaded_mod_moni[mod]['default']: + mod_conf[default_val] = loaded_mod_moni[mod]['default'][default_val] mod_conf['subscribers'] = {} self.db['global_conf'][mod] = mod_conf # removing entries of modules that are no loaded anymore @@ -501,11 +503,14 @@ class shelve_db: info_host["last_check"] = 0 info_host["warning"] = [] info_host["danger"] = [] + info_host["success"] = [] for mod in self.db["hosts"][host]["monitoring"]: if self.db["hosts"][host]["monitoring"][mod]["state"] == "warning": info_host["warning"].append(mod) elif self.db["hosts"][host]["monitoring"][mod]["state"] == "danger": info_host["danger"].append(mod) + else: + info_host["success"].append(mod) info_host['nb_subscribers'] = len(self.db['hosts'][host]['conf']['subscribers'].keys()) info_host['subscribers'] = self.db['hosts'][host]['conf']['subscribers'] info_host['display_name'] = self.db['hosts'][host]['conf']['display_name'] -- 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 d1d785850303557645ecdf44bc4a34a7ec41287b Merge: 45e342b fd2a1c1 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Jul 8 17:34:47 2015 +0200 Merge branch 'develop' of https://git.chorem.org/mum into develop .../detection_modules/kernel_snmp_detection.py | 36 ++++++++++++++++++++++ static/js/controllers/headCtrl.js | 6 +++- 2 files changed, 41 insertions(+), 1 deletion(-) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm