It would be great to be able to extend net-snmpd with custom "extend" scripts as described in the URL below. We're using this to enable monitoring of the WAN load balancing status via SNMP, but are now forced to patch the snmp.py script used to generate the snmpd.conf file.
http://net-snmp.sourceforge.net/wiki/index.php/Tut:Extending_snmpd_using_shell_scripts
--- /usr/libexec/vyos/conf_mode/snmp.py- 2019-03-15 10:17:57.965554124 +0100 +++ /usr/libexec/vyos/conf_mode/snmp.py 2019-03-15 10:17:50.321361722 +0100 @@ -102,6 +102,9 @@ smuxpeer .1.3.6.1.2.1.157 smuxsocket localhost +# Enable monitoring of WAN Load Balance status +extend wan-load-balance /config/scripts/nagios-wan-load-balance.sh + # linkUp/Down configure the Event MIB tables to monitor # the ifTable for network interfaces being taken up or down # for making internal queries to retrieve any necessary information
The script we're using:
#!/bin/sh WLB_OUT="/var/run/load-balance/wlb.out" if [ -f "$WLB_OUT" ]; then /bin/grep -q '^ Status: active$' "$WLB_OUT" if [ $? -eq 0 ]; then echo "OK - WAN Load balancing status - active" exit 0 else echo "WARNING - WAN Load balancing status - inactive" exit 1 fi else echo "UNKNOWN - WAN Load balancing not configured" exit 3 fi
The status can then be checked for example like this:
$ snmpwalk -v2c -c public 127.0.0.1 nsExtendOutput1 NET-SNMP-EXTEND-MIB::nsExtendOutput1Line."wan-load-balance" = STRING: OK - WAN Load balancing status - active NET-SNMP-EXTEND-MIB::nsExtendOutputFull."wan-load-balance" = STRING: OK - WAN Load balancing status - active NET-SNMP-EXTEND-MIB::nsExtendOutNumLines."wan-load-balance" = INTEGER: 1 NET-SNMP-EXTEND-MIB::nsExtendResult."wan-load-balance" = INTEGER: 0