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 9d2a82434b91d449fa7732d78edae4191a1b30d4 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Fri Jun 19 16:29:35 2015 +0200 exception raised on snmp_walk if no oid is found... + hostpage have a specific message if host is suspended + updated mum-daemon --- app/modules/connection_modules/snmp_walk.py | 10 +- mum-daemon.sh | 103 ++++--- views/hostpage.html | 406 ++++++++++++++-------------- 3 files changed, 281 insertions(+), 238 deletions(-) diff --git a/app/modules/connection_modules/snmp_walk.py b/app/modules/connection_modules/snmp_walk.py index a346de6..c3ddcd2 100644 --- a/app/modules/connection_modules/snmp_walk.py +++ b/app/modules/connection_modules/snmp_walk.py @@ -52,7 +52,15 @@ class SNMPWalk: else: for varBindTableRow in varBindTable: for name, val in varBindTableRow: - res[name.prettyPrint()] = val.prettyPrint() + if val.prettyPrint() != "": + # if this oid returned a result + res[name.prettyPrint()] = val.prettyPrint() + if res == {}: + # we got nothing for this oid => it doens't exists on this host + exception_inst = getattr(self.CommandNotFoundException, "CommandNotFoundException")( + cmd, self.addr_host + ) + raise exception_inst return res def disconnect(self): diff --git a/mum-daemon.sh b/mum-daemon.sh index 584fe3f..28290d5 100755 --- a/mum-daemon.sh +++ b/mum-daemon.sh @@ -1,52 +1,79 @@ -#! /bin/sh -e +#!/bin/sh -e +### BEGIN INIT INFO +# Provides: mum-daemon +# Required-Start: +# Required-Stop: +# Default-Start: S +# Default-Stop: +# Short-Description: Simple monitoring through a web interface. +### END INIT INFO -DAEMON="/usr/lib/mum/run.sh" #ligne de commande du programme -daemon_OPT="/etc/mum/mum.conf" #argument à utiliser par le programme -DAEMONUSER="user" #utilisateur du programme -daemon_NAME="run.sh" #Nom du programme (doit être identique à l'exécutable) +DESC="Mum service" +NAME="mum" -PATH="/sbin:/bin:/usr/sbin:/usr/bin" #Ne pas toucher +DAEMON=/usr/lib/mum/mum.sh +DAEMON_OPTS=/etc/mum +PIDFILE=/var/run/$NAME.pid + +SCRIPTNAME=/etc/init.d/mum-daemon.sh + +# Gracefully exit if the package has been removed. test -x $DAEMON || exit 0 . /lib/lsb/init-functions -d_start () { - log_daemon_msg "Starting system $daemon_NAME Daemon" - start-stop-daemon --background --name $daemon_NAME --start --quiet --chuid $DAEMONUSER --exec $DAEMON -- $daemon_OPT - log_end_msg $? +#test -f /etc/default/NetworkManager && . /etc/default/NetworkManager + +# +# Function that starts the daemon/service. +# +d_start() { + start-stop-daemon --start --quiet -b --pidfile $PIDFILE \ + --exec $DAEMON -- $DAEMON_OPTS } -d_stop () { - log_daemon_msg "Stopping system $daemon_NAME Daemon" - start-stop-daemon --name $daemon_NAME --stop --retry 5 --quiet --name $daemon_NAME - log_end_msg $? +# +# Function that stops the daemon/service. +# +d_stop() { + start-stop-daemon --stop --retry 5 --quiet --pidfile $PIDFILE \ + --exec $DAEMON } -case "$1" in - start|stop) - d_${1} - ;; - - restart|reload|force-reload) - d_stop - d_start - ;; - - force-stop) - d_stop - killall -q $daemon_NAME || true - sleep 2 - killall -q -9 $daemon_NAME || true - ;; - - status) - status_of_proc "$daemon_NAME" "$DAEMON" "system-wide $daemon_NAME" && exit 0 || exit $? - ;; - *) - echo "Usage: /etc/init.d/$daemon_NAME {start|stop|force-stop|restart|reload|force-reload|status}" - exit 1 - ;; +case "$1" in + start) + log_daemon_msg "Starting $DESC" "$NAME" + d_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_progress_msg "already started" + log_end_msg 0 ;; + *) log_end_msg 1 ;; + esac + ;; + stop) + log_daemon_msg "Stopping $DESC" "$NAME" + d_stop + case "$?" in + 0) log_end_msg 0 ;; + 1) log_progress_msg "already stopped" + log_end_msg 0 ;; + *) log_end_msg 1 ;; + esac + ;; + restart|force-reload) + $0 stop + $0 start + ;; + status) + status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $? + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2 + exit 1 + ;; esac + exit 0 \ No newline at end of file diff --git a/views/hostpage.html b/views/hostpage.html index f204aa5..db09a91 100644 --- a/views/hostpage.html +++ b/views/hostpage.html @@ -23,223 +23,231 @@ </small> </h1> - <p>There has been {{items.nb_warning}} warning(s) and {{items.nb_danger}} danger(s) since the last visit on this page.</p> - - <button type="button" - class="btn btn-primary btn-xs" - ng-click="open_modal_conn()">Connection settings</button> - - <button type="button" - class="btn btn-info btn-xs" - ng-click="launch_detection()">Launch a full detection</button> - - <button type="button" - class="btn btn-danger btn-xs" - ng-click="open_modal_confirm_delete()">Remove this host</button> - - <button type="button" - class="btn btn-{{get_idle_state()}} btn-xs" - aria-label="Button activation" - style="" - popover-placement="bottom" - popover="{{popover_message()}}" - popover-trigger="mouseenter" - ng-click="set_idle_state()"> - <span class="glyphicon glyphicon-off" aria-hidden="true"> - </span> - </button> - - <table class="table table-condensed table-hover" - ng-show="items.status != 'idling'"> - - <thead> - <tr> - <th>Part </th> - <th>Value </th> - <th>State </th> - <th>Last check </th> - </tr> - </thead> - - <tbody> - <tr ng-repeat-start="(modname, mod) in items.monitoring" - class={{mod.state}} - > <!-- ng-show="items.activated_monitoring[modname]" --> - <td>{{modname}}</td> - <td ng-show="get_type_of(mod.value) != 'object'"> - {{mod.value}} {{get_unit(modname)}} - </td> - <td ng-show="get_type_of(mod.value) == 'object'"> - <a ng-click="collapsed[modname] = !collapsed[modname]"> - {{get_maxvalue(modname)}} {{get_unit(modname)}} ▼ - </a> - </td> - <td> - {{mod.state}} - </td> - <td> - {{mod.date.split('.')[0]}} - </td> - <td> - <button type="button" class="btn btn-primary btn-xs" - ng-click="open_modal_conf(modname)">Configure - </button> - </td> - <td> - <button type="button" - class="btn btn-primary btn-xs" - ng-show="get_type_of(mod.value) != 'object'" - ng-click="open_modal_stats(addr_host, modname, '')">Archives - </button> - </td> - <td> - <button type="button" class="btn btn-info btn-xs" - ng-click="check(modname)">Check now - </button> - </td> - <td> - <button type="button" - class="btn btn-danger btn-xs" - aria-label="Stop monitoring of this part" - popover-placement="left" - popover="Stop the monitoring of this part" - popover-trigger="mouseenter" - ng-click="update_module_activation(modname, false)"> - <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> - </button> - </td> - </tr> - <tr ng-repeat-end - ng-repeat="(valname, val) in mod.value" - collapse="collapsed[modname]"> - <td>{{valname}}</td> - <td>{{val}} {{get_unit(modname)}}</td> - <td><button type="button" class="btn btn-primary btn-xs" - ng-click="open_modal_stats(addr_host, modname, valname)">Archives</button></td> - </tr> - </tbody> - - </table> - - <label for="add_mod_select">Add a part to monitore: </label> - <select id="add_mod_select" - ng-model="selected_mod_part"> - <optgroup ng-repeat="(blockname, block) in blocks" - label="{{blockname}}"> - <option ng-repeat="mod_obj in block" - ng-show="!mod_obj.activated" - ng-click="update_module_activation(mod_obj.modname, true)"> - {{mod_obj.modname}} - </option> - </optgroup> - </select> - - <!--<div ng-show="selected_mod_part!=''"> - {{selected_mod_part}}: compatible os: {{items.loaded_moni_mod[selected_mod_part].compatible_os}} <br/> - compatible connections: {{items.loaded_moni_mod[selected_mod_part].compatible_conn}} - </div>--> - - <accordion close-others="false"> - - <accordion-group heading="Essential configuration (nmap detection)"> - - <button type="button" class="btn btn-primary btn-xs" - ng-click="rescan()">Scan again</button> - - <table class="table table-bordered table-hover"> - <tr ng-repeat="(key, val) in items.detected.nmap"> - <td>{{key}}</td> - <td>{{val}}</td> - <td ng-show="(key == 'os')"> - <select ng-model="model.new_os" - ng-options="os for os in model.compatible_os_list"> - </select> - <button type="button" class="btn btn-info btn-xs" - ng-click="update_nmap_attribute('os', model.new_os)" - ng-disabled="model.new_os==''">Correct OS name</button> - </td> - <td ng-show="(key == 'hostname')"> - <input type="text" - ng-model="model.new_hostname"/> - <button type="button" class="btn btn-info btn-xs" - ng-click="update_nmap_attribute('hostname', model.new_hostname)" - ng-disabled="model.new_hostname==''">Correct hostname</button> - </td> - <td ng-show="(key == 'openports')"> - <button type="button" class="btn btn-primary btn-xs" - ng-click="open_modal_port_config(val)"> - Add/remove detected ports - </button> - </td> - </tr> - </table> - </accordion-group> - <accordion-group heading="Detected configuration (select the subparts to monitore here)"> - <table class="table table-bordered table-hover"> - <tr ng-repeat-start="(modname, mod) in items.detected" - ng-show="modname != 'nmap'"> - <th>{{modname}}</th> - <th> - <input type="checkbox" ng-model="selectedAll" ng-click="checkAll(modname, !selectedAll)"> - <button type="button" class="btn btn-info btn-xs" - ng-click="save_subpart(modname)"> - Monitore selected subparts - </button> - </th> - </tr> - <tr ng-repeat-end - ng-repeat="(key, val) in mod | orderBy : val" - ng-show="modname != 'nmap'"> - <td>{{val}}</td> - <td><input type="checkbox" ng-model="subparts_checked[modname][val]"></td> - </tr> - </table> + <button type="button" + class="btn btn-primary btn-xs" + ng-click="open_modal_conn()">Connection settings</button> - </accordion-group> + <button type="button" + class="btn btn-info btn-xs" + ng-click="launch_detection()">Launch a full detection</button> - <accordion-group heading="Custom informations"> + <button type="button" + class="btn btn-danger btn-xs" + ng-click="open_modal_confirm_delete()">Remove this host</button> - <label for="custom_info">Add any information here :</label> - <textarea class="form-control" rows="3" id="custom_info" ng-model="model.custom_infos"></textarea> - <button type="button" class="btn btn-info btn-xs" ng-click="save_custom_infos()">Save</button> + <button type="button" + class="btn btn-{{get_idle_state()}} btn-xs" + aria-label="Button activation" + style="" + popover-placement="bottom" + popover="{{popover_message()}}" + popover-trigger="mouseenter" + ng-click="set_idle_state()"> + <span class="glyphicon glyphicon-off" aria-hidden="true"> + </span> + </button> + + <div ng-show="get_idle_state() == 'success'"> + <p>There has been {{items.nb_warning}} warning(s) and {{items.nb_danger}} danger(s) consecutively.</p> + <table class="table table-condensed table-hover" + ng-show="items.status != 'idling'"> + + <thead> + <tr> + <th>Part </th> + <th>Value </th> + <th>State </th> + <th>Last check </th> + </tr> + </thead> + + <tbody> + <tr ng-repeat-start="(modname, mod) in items.monitoring" + class={{mod.state}} + > <!-- ng-show="items.activated_monitoring[modname]" --> + <td>{{modname}}</td> + <td ng-show="get_type_of(mod.value) != 'object'"> + {{mod.value}} {{get_unit(modname)}} + </td> + <td ng-show="get_type_of(mod.value) == 'object'"> + <a ng-click="collapsed[modname] = !collapsed[modname]"> + {{get_maxvalue(modname)}} {{get_unit(modname)}} ▼ + </a> + </td> + <td> + {{mod.state}} + </td> + <td> + {{mod.date.split('.')[0]}} + </td> + <td> + <button type="button" class="btn btn-primary btn-xs" + ng-click="open_modal_conf(modname)">Configure + </button> + </td> + <td> + <button type="button" + class="btn btn-primary btn-xs" + ng-show="get_type_of(mod.value) != 'object'" + ng-click="open_modal_stats(addr_host, modname, '')">Archives + </button> + </td> + <td> + <button type="button" class="btn btn-info btn-xs" + ng-click="check(modname)">Check now + </button> + </td> + <td> + <button type="button" + class="btn btn-danger btn-xs" + aria-label="Stop monitoring of this part" + popover-placement="left" + popover="Stop the monitoring of this part" + popover-trigger="mouseenter" + ng-click="update_module_activation(modname, false)"> + <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> + </button> + </td> + </tr> + <tr ng-repeat-end + ng-repeat="(valname, val) in mod.value" + collapse="collapsed[modname]"> + <td>{{valname}}</td> + <td>{{val}} {{get_unit(modname)}}</td> + <td><button type="button" class="btn btn-primary btn-xs" + ng-click="open_modal_stats(addr_host, modname, valname)">Archives</button></td> + </tr> + </tbody> + + </table> + + <label for="add_mod_select">Add a part to monitore: </label> + <select id="add_mod_select" + ng-model="selected_mod_part"> + <optgroup ng-repeat="(blockname, block) in blocks" + label="{{blockname}}"> + <option ng-repeat="mod_obj in block" + ng-show="!mod_obj.activated" + ng-click="update_module_activation(mod_obj.modname, true)"> + {{mod_obj.modname}} + </option> + </optgroup> + </select> - </accordion-group> + <!--<div ng-show="selected_mod_part!=''"> + {{selected_mod_part}}: compatible os: {{items.loaded_moni_mod[selected_mod_part].compatible_os}} <br/> + compatible connections: {{items.loaded_moni_mod[selected_mod_part].compatible_conn}} + </div>--> - <accordion-group heading="Interventions done"> + <accordion close-others="false"> - <button type="button" class="btn btn-primary btn-xs" - ng-click="open_modal_interv()">Add a new intervention</button> - <div ng-show="items.interventions != ''"> + <accordion-group heading="Essential configuration (nmap detection)"> + + <button type="button" class="btn btn-primary btn-xs" + ng-click="rescan()">Scan again</button> <table class="table table-bordered table-hover"> + <tr ng-repeat="(key, val) in items.detected.nmap"> + <td>{{key}}</td> + <td>{{val}}</td> + <td ng-show="(key == 'os')"> + <select ng-model="model.new_os" + ng-options="os for os in model.compatible_os_list"> + </select> + <button type="button" class="btn btn-info btn-xs" + ng-click="update_nmap_attribute('os', model.new_os)" + ng-disabled="model.new_os==''">Correct OS name</button> + </td> + <td ng-show="(key == 'hostname')"> + <input type="text" + ng-model="model.new_hostname"/> + <button type="button" class="btn btn-info btn-xs" + ng-click="update_nmap_attribute('hostname', model.new_hostname)" + ng-disabled="model.new_hostname==''">Correct hostname</button> + </td> + <td ng-show="(key == 'openports')"> + <button type="button" class="btn btn-primary btn-xs" + ng-click="open_modal_port_config(val)"> + Add/remove detected ports + </button> + </td> + </tr> + </table> - <thead> - <tr> - <th>Date </th> - <th>Person </th> - <th>Details </th> + </accordion-group> + + <accordion-group heading="Detected configuration (select the subparts to monitore here)"> + + <table class="table table-bordered table-hover"> + <tr ng-repeat-start="(modname, mod) in items.detected" + ng-show="modname != 'nmap'"> + <th>{{modname}}</th> + <th> + <input type="checkbox" ng-model="selectedAll" ng-click="checkAll(modname, !selectedAll)"> + <button type="button" class="btn btn-info btn-xs" + ng-click="save_subpart(modname)"> + Monitore selected subparts + </button> + </th> </tr> - </thead> - - <tbody> - <tr ng-repeat="interv in items.interventions | - orderBy:'-date'"> - <td>{{interv.date}}</td> - <td>{{interv.username}}</td> - <td>{{interv.details}}</td> + <tr ng-repeat-end + ng-repeat="(key, val) in mod | orderBy : val" + ng-show="modname != 'nmap'"> + <td>{{val}}</td> + <td><input type="checkbox" ng-model="subparts_checked[modname][val]"></td> </tr> - </tbody> - </table> - </div> + </accordion-group> + + <accordion-group heading="Custom informations"> + + <label for="custom_info">Add any information here :</label> + <textarea class="form-control" rows="3" id="custom_info" ng-model="model.custom_infos"></textarea> + <button type="button" class="btn btn-info btn-xs" ng-click="save_custom_infos()">Save</button> + + </accordion-group> + + <accordion-group heading="Interventions done"> + + <button type="button" class="btn btn-primary btn-xs" + ng-click="open_modal_interv()">Add a new intervention</button> + <div ng-show="items.interventions != ''"> + + <table class="table table-bordered table-hover"> + + <thead> + <tr> + <th>Date </th> + <th>Person </th> + <th>Details </th> + </tr> + </thead> + + <tbody> + <tr ng-repeat="interv in items.interventions | + orderBy:'-date'"> + <td>{{interv.date}}</td> + <td>{{interv.username}}</td> + <td>{{interv.details}}</td> + </tr> + </tbody> + + </table> + + </div> + + </accordion-group> - </accordion-group> + </accordion> + </div> - </accordion> + <div ng-show="get_idle_state() == 'danger'"> + The monitoring of this host is suspended... + </div> <script type="text/ng-template" id="modal_conf_label.html"> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.