Page MenuHomePhabricator

Allow SNMPd to be extended with custom scripts
Closed, ResolvedPublicFEATURE REQUEST

Description

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

Details

Difficulty level
Unknown (require assessment)
Version
-
Why the issue appeared?
Will be filled on close

Event Timeline

johanf created this task.Mar 15 2019, 9:44 AM
KKUL added a subscriber: KKUL.Mar 15 2019, 10:02 AM

Hello, I'm interested in that feature request as well.
And additionally, we want to monitor VRRP status via SNMP, assuming it can be done by pretty much the same way.
Thanks!

pasik added a subscriber: pasik.Mar 17 2019, 3:01 PM
syncer assigned this task to hagbard.Apr 17 2019, 7:44 PM
syncer triaged this task as Wishlist priority.
hagbard changed the task status from Open to In progress.Jun 17 2019, 7:12 PM

so I suppose something like: "set service snmp script1 [name path]" would do it?

https://github.com/vyos/vyos-1x/commit/334677572aef752b0bf2c893bd14bdf6f801bb4b

You need to upload your script to /config/user-data, once done you can configure it via 'set service snmp script-extensions extension-name <extensionname> script <script_name>'

Let me know if it works for you as expected, I think later on we can include script shipped with vyos, like you lb script.

hagbard changed the task status from In progress to Needs testing.Jul 15 2019, 6:42 PM
hagbard removed hagbard as the assignee of this task.Aug 1 2019, 8:16 PM
hagbard moved this task from In Progress to Backlog on the VyOS 1.2 Crux (VyOS 1.2.3) board.
hagbard added a subscriber: hagbard.
c-po moved this task from Finished to In Progress on the VyOS 1.3 Equuleus board.Aug 5 2019, 12:22 PM

Hello, this function works great, but I think it could be better if we can specify a custom OID for each custom script. For exemple, LibreNMS needs to have specific OID to make automatic OS/hardware detection working : https://docs.librenms.org/Support/SNMP-Configuration-Examples/#linux-snmpd-v2
Thank you.

hagbard closed this task as Resolved.Sep 25 2019, 3:48 PM
hagbard moved this task from Needs Triage to Backlog on the VyOS 1.2 Crux (VyOS 1.2.4) board.