branch develop updated (2d2c6ff -> 515d017)
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 2d2c6ff qques changements dans l'affichage des groupes + affichage des abonnements dans la page User new f27226f hostpage: bouton test de connection OK new a8438f1 regex utilisée pour sms_url new 515d017 app.py renommé en mum.py + le fichier de conf doit être passé en argument par ligne de commande + un argument en ligne de commande peut surcharger un champ du fichier de conf The 3 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 515d017f2255bf8b30bdc28f4fa83d14931c5885 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Fri Mar 27 16:54:55 2015 +0100 app.py renommé en mum.py + le fichier de conf doit être passé en argument par ligne de commande + un argument en ligne de commande peut surcharger un champ du fichier de conf commit a8438f1caec62e5117607d1617b6a2c041cdf3c0 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Fri Mar 27 11:44:19 2015 +0100 regex utilisée pour sms_url commit f27226f14d3b4949a18c7a29f37f7cd7c5dcae5f Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Fri Mar 27 11:13:44 2015 +0100 hostpage: bouton test de connection OK Summary of changes: app/module_loader.py | 21 ++++++++---- app/modules/notification_modules/sms_notif.py | 3 +- app/modules/storage_modules/shelve_db.py | 8 ++--- app/{app.py => mum.py} | 38 +++++++++++++++++++-- run.sh | 2 +- static/js/controllers/headCtrl.js | 8 +++++ static/js/controllers/hostPageCtrl.js | 7 ++++ views/hostpage.html | 3 +- views/profile.html | 49 +-------------------------- 9 files changed, 75 insertions(+), 64 deletions(-) rename app/{app.py => mum.py} (80%) -- 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 f27226f14d3b4949a18c7a29f37f7cd7c5dcae5f Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Fri Mar 27 11:13:44 2015 +0100 hostpage: bouton test de connection OK --- app/app.py | 8 ++++++++ app/module_loader.py | 12 ++++++++++++ static/js/controllers/headCtrl.js | 8 ++++++++ static/js/controllers/hostPageCtrl.js | 7 +++++++ views/hostpage.html | 3 ++- 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/app/app.py b/app/app.py index 7ec70c8..eca0266 100755 --- a/app/app.py +++ b/app/app.py @@ -11,6 +11,7 @@ import threading from module_loader import ModuleLoader import process_monitoring from modules.notification_modules.websocket_container import WebSocketContainer +import traceback # Pour lancer la detection nmap avec un nouveau thread class ThreadDetect(threading.Thread): @@ -149,6 +150,13 @@ def receive(ws): ws.send(json_dumps({"RES_GET_LOADED_NOTIF_MOD": ml.get_info_mod_notification()})) elif code == "SET_MOD_ACTIVATION": # asked from hostpage, at the block activation conf ml.update_activated_modules(msg["SET_MOD_ACTIVATION"]) + elif code == "TEST_CONN": + try: + ml.test_connection(msg["TEST_CONN"]["addr_host"], + msg["TEST_CONN"]["conn_mod_name"]) + ws.send(json_dumps({"RES_TEST_CONN": True})) + except Exception: + ws.send(json_dumps({"RES_TEST_CONN": False})) elif code == "SET_CONF_MOD": # asked from hostpage, at the monitoring module configuration ml.launch_db_function({'func': 'set_conf_mod', 'args': msg["SET_CONF_MOD"]}) process_monitoring.update_mod_on_waiting_list(msg["SET_CONF_MOD"]) diff --git a/app/module_loader.py b/app/module_loader.py index 4ad1949..f70696e 100644 --- a/app/module_loader.py +++ b/app/module_loader.py @@ -92,6 +92,18 @@ class ModuleLoader: print "Error: no connection have been configured yet" return mod_inst + def test_connection(self, addr_host, conn_mod_name): + avaliable_conn = self.db.get_conf_conn(addr_host) + conn = None + for i in range(len(avaliable_conn)): + if avaliable_conn[i]['conn_mod_name'] == conn_mod_name: + conn = avaliable_conn.pop(i) + getattr(self.loaded_mod_conn[conn['conn_mod_name']]['imported'], + self.loaded_mod_conn[conn['conn_mod_name']]['class_name'])(addr_host, + conn['args'], + self.conf['keys_location'], + modules.CommandNotFoundException) + def load_all_detection_modules(self): """ Instanciates and stores the informations about each monitoring modules avaliable on the loaded_mod_detect attribute diff --git a/static/js/controllers/headCtrl.js b/static/js/controllers/headCtrl.js index 1d87198..f70426a 100644 --- a/static/js/controllers/headCtrl.js +++ b/static/js/controllers/headCtrl.js @@ -53,6 +53,14 @@ mumApp.controller('headCtrl', function($scope, $rootScope, toastr, $interval, $r case "RES_CALL_FUNC_DB": // Get a result after calling a funcion on the db $rootScope.$broadcast("resCall", obj[key]); break; + case "RES_TEST_CONN": + if(obj[key]){ // if success of the connection + $scope.pop_success("Connection test", "The connection is well configured."); + } + else{ + $scope.pop_danger("Connection test", "The connection could not have been established. Please verify its configuration."); + } + break; case "CURRENT_STATE_INFO": $scope.$apply(function(){ $scope.state = obj[key]; diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index 3b475a8..61a3b01 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -307,6 +307,13 @@ mumApp.controller('ModalConnInstanceCtrl', function ($scope, $rootScope, $modalI } }); + $scope.testConn = function(connModName){ + var args = {}; + args['addr_host'] = $scope.conn_args["addr_host"]; + args['conn_mod_name'] = connModName; + $rootScope.$broadcast("sendViaWs", JSON.stringify({"TEST_CONN": args})); + } + $scope.ok = function () { var args = {}; args['addr_host'] = $scope.conn_args.addr_host; diff --git a/views/hostpage.html b/views/hostpage.html index c579267..7359ec9 100644 --- a/views/hostpage.html +++ b/views/hostpage.html @@ -193,7 +193,8 @@ <td> <button type="button" class="btn btn-primary" ng-click="open_modal_conf_conn(modname)">Advanced configuration</button> - <button type="button" class="btn btn-success">Test</button> + <button type="button" class="btn btn-success" + ng-click="testConn(modname)">Test</button> </td> </tr> -- 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 a8438f1caec62e5117607d1617b6a2c041cdf3c0 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Fri Mar 27 11:44:19 2015 +0100 regex utilisée pour sms_url --- app/modules/notification_modules/sms_notif.py | 3 +- app/modules/storage_modules/shelve_db.py | 8 ++--- views/profile.html | 49 +-------------------------- 3 files changed, 7 insertions(+), 53 deletions(-) diff --git a/app/modules/notification_modules/sms_notif.py b/app/modules/notification_modules/sms_notif.py index b20438f..1ddad7c 100644 --- a/app/modules/notification_modules/sms_notif.py +++ b/app/modules/notification_modules/sms_notif.py @@ -1,6 +1,7 @@ __author__ = 'aguilbaud' import urllib2 +import re def get_class_name(): return "SMS" @@ -18,7 +19,7 @@ class SMS: return self.name def notify(self): - url = self.user_data['sms_url'] + self.msg + url = re.sub(r'#message#', self.msg, self.user_data['sms_url']) req = urllib2.Request(url) try: diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index 083e7c4..42aac7a 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -773,8 +773,8 @@ class shelve_db: ... } """ - title = "[Mum] " + status + " on " + addr_host - msg = "Mum repported a " + status + " value by the " + moni_mod + " mod " + title = "[Mum] " + status + " for " + addr_host + msg = "Mum repported a " + status + " value from the " + moni_mod + " module. " dict_notif = {} notif_type = "" if status == 'warning': @@ -803,7 +803,7 @@ class shelve_db: if param_notif['activated']: title = "[Mum] " + status + " for " + addr_host + " on group " + group msg = "Mum repported a " + status + " from the " + moni_mod + " module on host " + \ - addr_host + " member of group " + group + addr_host + " member of group " + group + "." if notif_mod not in dict_notif: dict_notif[notif_mod] = [] dict_notif[notif_mod].append({'user': self.db['users'][username]['settings'], @@ -1029,7 +1029,7 @@ class shelve_db: """ self.open_db() try: - self.db['users'][args['user']]['settings'] = args['settings'] + self.db['users'][args['username']]['settings'] = args['settings'] except Exception: print traceback.format_exc() finally: diff --git a/views/profile.html b/views/profile.html index 39b8411..d3d5f94 100644 --- a/views/profile.html +++ b/views/profile.html @@ -35,7 +35,7 @@ </div> <div class="row"></div> <div class="col-xs-8"> - <label for="cellphone">SMS URL</label> + <label for="cellphone">SMS URL (put #message# on the message parameter)</label> <input type="text" class="form-control" id="cellphone" ng-model="sms_url"> </div> </div> @@ -142,51 +142,4 @@ <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="close()">Close</button> </div> </script> - <!--<h3>Summary of notification subscriptions</h3> - <p>Number of notifications between your last login</p> - <table class="table table-hover"> - <thead> - <tr> - <th>Host/Group</th> - <th>Notification service</th> - <th>Minor</th> - <th>Major</th> - </tr> - </thead> - <tbody> - <tr> - <td rowspan="2">mygroup2</td> - <td>Browser</td> - <td class="success">1</td> - <td class="success">1</td> - </tr> - <tr> - <td>E-mail</td> - <td></td> - <td class="success">3</td> - </tr> - <tr> - <td>142.42.13.37</td> - <td>E-mail</td> - <td class="success">3</td> - <td class="success">1</td> - </tr> - <tr> - <td rowspan="3">192.168.74.1</td> - <td>Browser</td> - <td class="success">1</td> - <td class="success">1</td> - </tr> - <tr> - <td>E-mail</td> - <td></td> - <td class="success">3</td> - </tr> - <tr> - <td>SMS</td> - <td></td> - <td class="success">5</td> - </tr> - </tbody> - </table>--> </div> \ No newline at end of file -- 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 515d017f2255bf8b30bdc28f4fa83d14931c5885 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Fri Mar 27 16:54:55 2015 +0100 app.py renommé en mum.py + le fichier de conf doit être passé en argument par ligne de commande + un argument en ligne de commande peut surcharger un champ du fichier de conf --- app/module_loader.py | 9 ++------- app/{app.py => mum.py} | 32 +++++++++++++++++++++++++++++--- run.sh | 2 +- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/app/module_loader.py b/app/module_loader.py index f70696e..638692a 100644 --- a/app/module_loader.py +++ b/app/module_loader.py @@ -21,13 +21,8 @@ class ModuleLoader: Loads dynamically modules from packages connection_modules, detection_modules, monitoring_modules, storage_modules and contains several methods in order to call the methods once these modules loaded. """ - def __init__(self, add_func, rem_func): - self.conf = {} # See conf.txt - fconf = open('mum.conf', 'r') - for line in fconf.read().splitlines(): - fields = line.split('=') - self.conf[fields[0]] = fields[1] - fconf.close() + def __init__(self, add_func, rem_func, conf): + self.conf = conf ''' self.db_loc = dict_conf['db_location'] self.external_mod_loc = dict_conf['external_modules_location'] diff --git a/app/app.py b/app/mum.py similarity index 85% rename from app/app.py rename to app/mum.py index eca0266..89bf69c 100755 --- a/app/app.py +++ b/app/mum.py @@ -11,7 +11,7 @@ import threading from module_loader import ModuleLoader import process_monitoring from modules.notification_modules.websocket_container import WebSocketContainer -import traceback +import argparse # Pour lancer la detection nmap avec un nouveau thread class ThreadDetect(threading.Thread): @@ -186,7 +186,33 @@ def do_upload(): if __name__ == '__main__': global ml global wsc - ml = ModuleLoader(process_monitoring.add_to_waiting_list, process_monitoring.remove_to_waiting_list) + + # creating the parser for the command line arguments + parser = argparse.ArgumentParser() + parser.add_argument("conf_loc", help="the location of the configuration file (can be relative)") + parser.add_argument("--db_location", help="the location of the shelve database") + parser.add_argument("--external_modules_location", help="the location of the external monitoring modules") + parser.add_argument("--keys_location", help="the location of the directory containing the SSH keys") + parser.add_argument("--smtp_server", help="the name of the SMTP server to send e-mail notifications") + parser.add_argument("--smtp_port", help="the port of the SMTP server") + parser.add_argument("--smtp_address", help="the e-mail address of the sender for the e-mail notifications") + args = parser.parse_args() + + # creating the default conf structure from the configuration file + conf = {} + fconf = open(args.conf_loc, 'r') + for line in fconf.read().splitlines(): + fields = line.split('=') + conf[fields[0]] = fields[1] + fconf.close() + + # now, we overwrite each field of the configuration which are specified by command line argument + dict_args = vars(args) + for arg in dict_args: + if dict_args[arg] is not None: + conf[arg] = dict_args[arg] + + ml = ModuleLoader(process_monitoring.add_to_waiting_list, process_monitoring.remove_to_waiting_list, conf) ml.load_all_monitoring_modules() ml.load_all_connection_modules() ml.load_all_detection_modules() @@ -198,4 +224,4 @@ if __name__ == '__main__': port = int(os.environ.get('PORT', 1337)) run(host='0.0.0.0', port=port, debug=True, server=GeventWebSocketServer) # after ending - process_monitoring.end = True + process_monitoring.end = True \ No newline at end of file diff --git a/run.sh b/run.sh index 7bb42c9..a0599c6 100755 --- a/run.sh +++ b/run.sh @@ -1,3 +1,3 @@ #!/bin/sh -exec ./in-venv.sh python app/app.py $* +exec ./in-venv.sh python app/mum.py $* -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm