This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
wiki:systeme_mana:monitoring [2019/09/25 15:37] ghi created |
wiki:systeme_mana:monitoring [2022/09/14 15:13] (current) cgu [Persistency on Update] |
||
|---|---|---|---|
| Line 15: | Line 15: | ||
| ===== SNMP agent ===== | ===== SNMP agent ===== | ||
| - | Simple Network Management Protocol (SNMP) is a protocol used for monitoring network equipments. The data SNMP management is organized in a management information base (MIB). SNMP agent on Kerlink gateways is based on net-snmp (Net-SNMP). It is included by default with the firmware, and started automatically. | + | |
| + | Simple Network Management Protocol (SNMP) is a protocol used for monitoring network equipment. The data SNMP management is organized in a management information base (MIB). SNMP agent on Kerlink gateways is based on net-snmp (Net-SNMP). It is included by default with the firmware, however, since this is a generic agent, a few modifications are required to use it. | ||
| + | |||
| + | |||
| + | ==== Configuration ==== | ||
| + | Configuration file must be in ''/etc/snmp/''. | ||
| + | |||
| + | By default, no configuration (''/etc/snmp/snmpd.conf'') is provided.\\ | ||
| + | Create the folder ''/etc/snmp'' and the file ''/etc/snmp/snmpd.conf''.\\ | ||
| + | Here under a valid basic configuration: | ||
| + | |||
| + | <code conf snmpd.conf> | ||
| + | ########################################################################### | ||
| + | # | ||
| + | # snmpd.conf | ||
| + | # | ||
| + | |||
| + | ########################################################################### | ||
| + | # SECTION: Access Control Setup | ||
| + | # | ||
| + | # This section defines who is allowed to talk to your running | ||
| + | # snmp agent. | ||
| + | |||
| + | # rwcommunity: a SNMPv1/SNMPv2c read-write access community name | ||
| + | # arguments: community [default|hostname|network/bits] [oid] | ||
| + | |||
| + | rocommunity public | ||
| + | rwcommunity private | ||
| + | |||
| + | # | ||
| + | # Unknown directives read in from other files by snmpconf | ||
| + | # | ||
| + | com2sec readwrite "default" public | ||
| + | com2sec readwrite "default" private | ||
| + | |||
| + | # Agent port | ||
| + | agentAddress udp:161 | ||
| + | |||
| + | ########################################################################### | ||
| + | # SECTION: Trap Destinations | ||
| + | # | ||
| + | # Here we define who the agent will send traps to. | ||
| + | |||
| + | informsink <your_server> public 162 | ||
| + | |||
| + | # authtrapenable: Should we send traps when authentication failures occur | ||
| + | # arguments: 1 | 2 (1 = yes, 2 = no) | ||
| + | authtrapenable 1 | ||
| + | </code> | ||
| <note warning> | <note warning> | ||
| - | Check your **[[wiki:firewall|firewall]]** and note that SNMP ports should be opened to properly work! | + | Check your **[[wiki:network_mana:firewall|firewall]]** and note that SNMP ports (by default 161 and 162) should be opened to properly work! |
| </note> | </note> | ||
| - | To disable ''SNMPD'' from running at startup use the following commands: | ||
| - | <code> | + | |
| - | echo SNMPDRUN=no > /etc/default/snmpd | + | ==== Automatic Execution ==== |
| - | reboot | + | To automatically execute ''snmpd'' at boot time, a script named ''snmpd'' needs to be created in a new folder ''/etc/init.d/''. |
| + | |||
| + | * Copy the following script under ''/etc/init.d/snmpd''. | ||
| + | <code init snmpd.init> | ||
| + | #! /bin/sh -e | ||
| + | ### BEGIN INIT INFO | ||
| + | # Provides: snmpd | ||
| + | # Required-Start: $network $local_fs | ||
| + | # Required-Stop: $network $local_fs | ||
| + | # Default-Start: 2 3 4 5 | ||
| + | # Default-Stop: 0 6 | ||
| + | # Short-Description: SNMP agents | ||
| + | # Description: NET SNMP (Simple Network Management Protocol) Agents | ||
| + | ### END INIT INFO | ||
| + | # | ||
| + | set -e | ||
| + | |||
| + | export PATH=/sbin:/usr/sbin:/bin:/usr/bin | ||
| + | |||
| + | test -x /usr/sbin/snmpd || exit 0 | ||
| + | |||
| + | # Defaults | ||
| + | export MIBDIRS=/usr/share/snmp/mibs | ||
| + | SNMPDRUN=yes | ||
| + | SNMPDOPTS='-Lsd -p /var/run/snmpd.pid' | ||
| + | TRAPDRUN=no | ||
| + | TRAPDOPTS='-Lsd -p /var/run/snmptrapd.pid' | ||
| + | |||
| + | # Reads config file (will override defaults above) | ||
| + | [ -r /etc/default/snmpd ] && . /etc/default/snmpd | ||
| + | |||
| + | ssd_oknodo="-o" | ||
| + | |||
| + | # Cd to / before starting any daemons. | ||
| + | cd / | ||
| + | |||
| + | # Create compatibility link to old AgentX socket location | ||
| + | if [ "$SNMPDCOMPAT" = "yes" ]; then | ||
| + | ln -sf /var/agentx/master /var/run/agentx | ||
| + | fi | ||
| + | |||
| + | case "$1" in | ||
| + | start) | ||
| + | printf "Starting network management services:" | ||
| + | if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then | ||
| + | start-stop-daemon -S -x /usr/sbin/snmpd -- $SNMPDOPTS | ||
| + | printf " snmpd" | ||
| + | fi | ||
| + | echo "." | ||
| + | ;; | ||
| + | stop) | ||
| + | printf "Stopping network management services:" | ||
| + | start-stop-daemon -q -K $ssd_oknodo -x /usr/sbin/snmpd | ||
| + | printf " snmpd" | ||
| + | echo "." | ||
| + | ;; | ||
| + | restart) | ||
| + | printf "Restarting network management services:" | ||
| + | start-stop-daemon -q -K $ssd_oknodo -x /usr/sbin/snmpd | ||
| + | # Allow the daemons time to exit completely. | ||
| + | sleep 2 | ||
| + | if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then | ||
| + | start-stop-daemon -q -S -x /usr/sbin/snmpd -- $SNMPDOPTS | ||
| + | printf " snmpd" | ||
| + | fi | ||
| + | echo "." | ||
| + | ;; | ||
| + | reload|force-reload) | ||
| + | printf "Reloading network management services:" | ||
| + | if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then | ||
| + | start-stop-daemon -q -K -s 1 -p /var/run/snmpd.pid -x /usr/sbin/snmpd | ||
| + | printf " snmpd" | ||
| + | fi | ||
| + | echo "." | ||
| + | ;; | ||
| + | *) | ||
| + | echo "Usage: /etc/init.d/snmpd {start|stop|restart|reload|force-reload}" | ||
| + | exit 1 | ||
| + | esac | ||
| + | |||
| + | exit 0 | ||
| </code> | </code> | ||
| + | |||
| + | * Apply executable right to the script: | ||
| + | <code>chmod 700 /etc/init.d/snmpd</code> | ||
| + | |||
| + | * Create a symbolic link in ''rcU.d'' to the script so so it is executed at boot time. | ||
| + | <code>ln -s /etc/init.d/snmpd /etc/rcU.d/S59snmpd</code> | ||
| + | |||
| + | * Create a symbolic link in ''rcK.d'' to the script so so it is executed when the system halts. | ||
| + | <code>ln -s /etc/init.d/snmpd /etc/rcK.d/K59snmpd</code> | ||
| + | |||
| + | * Reboot the Wirnet™ gateway (''reboot'' command) or type the below command to start ''snmpd'': | ||
| + | <code>/etc/init.d/snmpd start</code> | ||
| + | |||
| + | * A monitoring task can be added thanks to [[wiki:systeme_mana:monitoring#monit_daemon|Monit daemon]]. | ||
| + | ==== Persistency on Update ==== | ||
| + | in order to make the configuration stay after an update you will need to create the file snmp.conf in the folder /etc/sysupgrade.d/ with the three following lines: | ||
| + | <code conf snmp.conf> | ||
| + | /etc/init.d/snmpd | ||
| + | /etc/rcU.d/S59snmpd | ||
| + | /etc/rcK.d/K59snmpd | ||
| + | </code> | ||
| + | |||
| ===== Supported MIBs ===== | ===== Supported MIBs ===== | ||