Snmp “extend” to OpenWrt Meraki MR33

I discovered recently that Librenms is capable to “handle” and show wifi sensors and because i had a OpenWrt AP running i tried to have it running but…

It wasn’t running as it was described. Here i would like to explain what i did to make it running.
Two issues that are not discribed in the documentation:

  1. Librenms don’t have MIB or snmp-mibs.
  2. OpenWrt had a bug that doesn’t have “extend’ feature enabled in my running SNMP application.

For problem number 1. If you try to see if your code running, Librenms give you some errors:

librenms@librenms:~$ snmpwalk -v 2c -c public -Osqnv 192.168.24.38 'NET-SNMP-EXTEND-MIB::nsExtendOutputFull."frequency-wlan1"'
MIB search path: /opt/librenms/.snmp/mibs:/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp
Cannot find module (SNMP-FRAMEWORK-MIB): At line 9 in /usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt
Cannot find module (SNMPv2-SMI): At line 8 in /usr/share/snmp/mibs/NET-SNMP-MIB.txt
Did not find 'enterprises' in module #-1 (/usr/share/snmp/mibs/NET-SNMP-MIB.txt)
Unlinked OID in NET-SNMP-MIB: netSnmp ::= { enterprises 8072 }
Undefined identifier: enterprises near line 10 of /usr/share/snmp/mibs/NET-SNMP-MIB.txt
Cannot find module (SNMPv2-TC): At line 21 in /usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt
Did not find 'SnmpAdminString' in module #-1 (/usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt)
Did not find 'netSnmpObjects' in module NET-SNMP-MIB (/usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt)
Did not find 'netSnmpModuleIDs' in module NET-SNMP-MIB (/usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt)
Did not find 'netSnmpNotifications' in module NET-SNMP-MIB (/usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt)
Did not find 'netSnmpGroups' in module NET-SNMP-MIB (/usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt)
Did not find 'DisplayString' in module #-1 (/usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt)
Did not find 'RowStatus' in module #-1 (/usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt)
Did not find 'TruthValue' in module #-1 (/usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt)
Unlinked OID in NET-SNMP-AGENT-MIB: nsAgentNotifyGroup ::= { netSnmpGroups 9 }
Undefined identifier: netSnmpGroups near line 545 of /usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt
Unlinked OID in NET-SNMP-AGENT-MIB: nsTransactionGroup ::= { netSnmpGroups 8 }
Undefined identifier: netSnmpGroups near line 536 of /usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt
Unlinked OID in NET-SNMP-AGENT-MIB: nsConfigGroups ::= { netSnmpGroups 7 }
Undefined identifier: netSnmpGroups near line 515 of /usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt
Unlinked OID in NET-SNMP-AGENT-MIB: nsCacheGroup ::= { netSnmpGroups 4 }
Undefined identifier: netSnmpGroups near line 505 of /usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt
Unlinked OID in NET-SNMP-AGENT-MIB: nsModuleGroup ::= { netSnmpGroups 2 }
Undefined identifier: netSnmpGroups near line 495 of /usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt
Unlinked OID in NET-SNMP-AGENT-MIB: netSnmpAgentMIB ::= { netSnmpModuleIDs 2 }
Undefined identifier: netSnmpModuleIDs near line 24 of /usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt
Unlinked OID in NET-SNMP-AGENT-MIB: nsTransactions ::= { netSnmpObjects 8 }
Undefined identifier: netSnmpObjects near line 55 of /usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt
Unlinked OID in NET-SNMP-AGENT-MIB: nsConfiguration ::= { netSnmpObjects 7 }
Undefined identifier: netSnmpObjects near line 54 of /usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt
Unlinked OID in NET-SNMP-AGENT-MIB: nsErrorHistory ::= { netSnmpObjects 6 }
Undefined identifier: netSnmpObjects near line 53 of /usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt
Unlinked OID in NET-SNMP-AGENT-MIB: nsCache ::= { netSnmpObjects 5 }
Undefined identifier: netSnmpObjects near line 52 of /usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt
Unlinked OID in NET-SNMP-AGENT-MIB: nsDLMod ::= { netSnmpObjects 4 }
Undefined identifier: netSnmpObjects near line 51 of /usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt
Unlinked OID in NET-SNMP-AGENT-MIB: nsExtensions ::= { netSnmpObjects 3 }
Undefined identifier: netSnmpObjects near line 50 of /usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt
Unlinked OID in NET-SNMP-AGENT-MIB: nsMibRegistry ::= { netSnmpObjects 2 }
Undefined identifier: netSnmpObjects near line 49 of /usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt
Unlinked OID in NET-SNMP-AGENT-MIB: nsVersion ::= { netSnmpObjects 1 }
Undefined identifier: netSnmpObjects near line 48 of /usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt
Unlinked OID in NET-SNMP-AGENT-MIB: nsNotifyRestart ::= { netSnmpNotifications 3 }
Undefined identifier: netSnmpNotifications near line 482 of /usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt
Unlinked OID in NET-SNMP-AGENT-MIB: nsNotifyShutdown ::= { netSnmpNotifications 2 }
Undefined identifier: netSnmpNotifications near line 476 of /usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt
Unlinked OID in NET-SNMP-AGENT-MIB: nsNotifyStart ::= { netSnmpNotifications 1 }
Undefined identifier: netSnmpNotifications near line 470 of /usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt
Did not find 'nsExtensions' in module NET-SNMP-AGENT-MIB (/usr/share/snmp/mibs/NET-SNMP-EXTEND-MIB.txt)
Did not find 'DisplayString' in module #-1 (/usr/share/snmp/mibs/NET-SNMP-EXTEND-MIB.txt)
Did not find 'RowStatus' in module #-1 (/usr/share/snmp/mibs/NET-SNMP-EXTEND-MIB.txt)
Did not find 'StorageType' in module #-1 (/usr/share/snmp/mibs/NET-SNMP-EXTEND-MIB.txt)
Unlinked OID in NET-SNMP-EXTEND-MIB: nsExtendGroups ::= { nsExtensions 3 }
Undefined identifier: nsExtensions near line 39 of /usr/share/snmp/mibs/NET-SNMP-EXTEND-MIB.txt
Unlinked OID in NET-SNMP-EXTEND-MIB: nsExtendObjects ::= { nsExtensions 2 }
Undefined identifier: nsExtensions near line 38 of /usr/share/snmp/mibs/NET-SNMP-EXTEND-MIB.txt
Unlinked OID in NET-SNMP-EXTEND-MIB: netSnmpExtendMIB ::= { nsExtensions 1 }
Undefined identifier: nsExtensions near line 19 of /usr/share/snmp/mibs/NET-SNMP-EXTEND-MIB.txt
NET-SNMP-EXTEND-MIB::nsExtendOutputFull."frequency-wlan1": Unknown Object Identifier

This can be fixed with:

 sudo apt-get install snmp-mibs-downloader

For problem nr. 2. Things are more complex here. There is a way to upgrade your OpenWrt instance to 19.07.3 software version. The problem was that the AP was somewhere remotely and if had some issues with upgrading, i don’t want to spend the entire night fixing it.

I discovered that some others have this problem and i tried to modify the script that generate the snmp configuration file to see if i can fix this.

I tried to edit the file “/etc/init.d/snmpd”:


-snmpd_exec_add() {
+snmpd_extend_add() {
        local cfg="$1"
 
        config_get name "$cfg" name
@@ -184,7 +184,7 @@ snmpd_exec_add() {
        [ -n "$prog" ] || return 0
        config_get args "$cfg" args
        config_get miboid "$cfg" miboid
-       echo "exec $miboid $name $prog $args" >> $CONFIGFILE
+       echo "$1 $miboid $name $prog $args" >> $CONFIGFILE
 }
 
 snmpd_disk_add() {
@@ -293,7 +293,8 @@ start_service() {
        config_foreach snmpd_access_HostName_add access_HostName
        config_foreach snmpd_access_HostIP_add access_HostIP
        config_foreach snmpd_pass_add pass
-       config_foreach snmpd_exec_add exec
+       config_foreach snmpd_extend_add extend
+       config_foreach snmpd_extend_add exec
        config_foreach snmpd_disk_add disk
        config_foreach snmpd_engineid_add engineid
        append_parm trapcommunity community trapcommunity

Adding this “extended” feature broke up even “exec” feature.
What is the difference between “extended” and “exec” ? This is explained here or :

'exec' will run the specified command and return the exit status and output. Any arguments are passed directly to the command, with no special interpretation.

'extend' is also similar, but provides a richer and more flexible MIB framework – both for configuring the exact command to be run, and for displaying the results.

Then i tried to search for “snmpd_extend_add() {” to see if there is somewhere else this code, maybe fixed. I found this.
So to fix our code we have to leave the code as it is but add this:

snmpd_extend_add() {
	local cfg="$1"

	config_get name "$cfg" name
	[ -n "$name" ] || return 0
	config_get prog "$cfg" prog
	[ -n "$prog" ] || return 0
	config_get args "$cfg" args
	config_get miboid "$cfg" miboid
	echo "extend $miboid $name $prog $args" >> $CONFIGFILE
}

This code should be between “snmpd_exec_add” and “snmpd_disk_add”.
Then we are trying to find this line that start with :

start_service() {

and add after:

config_foreach snmpd_exec_add exec

this:

config_foreach snmpd_extend_add extend

Now our snmp script application is fixed and now we have “extend” feature. We can test this using:

root@OpenWrt:/tmp# cat /etc/snmp/snmpd.conf
agentaddress UDP:161,UDP6:161
master agentx
agentXSocket /var/run/agentx.sock
sysLocation Somewhere
sysContact [email protected]
sysName ap-somewhere.local
com2sec ro default public
com2sec rw localhost private
com2sec6 ro default public
com2sec6 rw localhost private
group public v1 ro
group public v2c ro
group public usm ro
group private v1 rw
group private v2c rw
group private usm rw
view all included .1
access public "" any noauth exact all none none
access private "" any noauth exact all all all
exec  filedescriptors /bin/cat /proc/sys/fs/file-nr
exec .1.3.6.1.4.1.2021.7890.1 distro /usr/bin/distro
extend  interfaces /bin/cat /etc/librenms/wlInterfaces.txt
extend  clients-wlan1 /etc/librenms/wlClients.sh wlan1
extend  clients-wlan2 /etc/librenms/wlClients.sh wlan2
extend  clients-wlan /etc/librenms/wlClients.sh
extend  frequency-wlan1 /etc/librenms/wlFrequency.sh wlan1
extend  frequency-wlan2 /etc/librenms/wlFrequency.sh wlan2
extend  rate-tx-wlan1-min /etc/librenms/wlRate.sh wlan1 tx min
extend  rate-tx-wlan1-avg /etc/librenms/wlRate.sh wlan1 tx avg
extend  rate-tx-wlan1-max /etc/librenms/wlRate.sh wlan1 tx max
extend  rate-tx-wlan2-min /etc/librenms/wlRate.sh wlan2 tx min
extend  rate-tx-wlan2-avg /etc/librenms/wlRate.sh wlan2 tx avg
extend  rate-tx-wlan2-max /etc/librenms/wlRate.sh wlan2 tx max
extend  rate-rx-wlan1-min /etc/librenms/wlRate.sh wlan1 rx min
extend  rate-rx-wlan1-avg /etc/librenms/wlRate.sh wlan1 rx avg
extend  rate-rx-wlan1-max /etc/librenms/wlRate.sh wlan1 rx max
extend  rate-rx-wlan2-min /etc/librenms/wlRate.sh wlan2 rx min
extend  rate-rx-wlan2-avg /etc/librenms/wlRate.sh wlan2 rx avg
extend  rate-rx-wlan2-max /etc/librenms/wlRate.sh wlan2 rx max
extend  noise-floor-wlan1 /etc/librenms/wlNoiseFloor.sh wlan1
extend  noise-floor-wlan2 /etc/librenms/wlNoiseFloor.sh wlan2
extend  snr-wlan1-min /etc/librenms/wlSNR.sh wlan1 min
extend  snr-wlan1-avg /etc/librenms/wlSNR.sh wlan1 avg
extend  snr-wlan1-max /etc/librenms/wlSNR.sh wlan1 max
extend  snr-wlan2-min /etc/librenms/wlSNR.sh wlan2 min
extend  snr-wlan2-avg /etc/librenms/wlSNR.sh wlan2 avg
extend  snr-wlan2-max /etc/librenms/wlSNR.sh wlan2 max
engineIDType 3
engineIDNic eth0
root@OpenWrt:/tmp#

To have the distribution discovered by Librenms, we have to fix this by creating /usr/bin/distro using:

vim /usr/bin/distro 

And add inside the file this script:

#!/bin/ash
[ -f /etc/openwrt_release ] && source /etc/openwrt_release
echo ${DISTRIB_ID} ${DISTRIB_RELEASE} ${DISTRIB_REVISION}

Make sure you have the proper permission:

chmod +x /usr/bin/distro 

And now if we run the file:

root@OpenWrt:/tmp#  /usr/bin/distro
OpenWrt 18.06.5 r7897-9d401013fc

Here is how SNMP is configured:

root@OpenWrt:/tmp# cat /etc/config/snmpd
config agent
        option agentaddress UDP:161,UDP6:161

config agentx
        option agentxsocket /var/run/agentx.sock

config com2sec public
        option secname ro
        option source default
        option community public

config com2sec private
        option secname rw
        option source localhost
        option community private

config com2sec6 public6
        option secname ro
        option source default
        option community public

config com2sec6 private6
        option secname rw
        option source localhost
        option community private

config group public_v1
        option group public
        option version v1
        option secname ro

config group public_v2c
        option group public
        option version v2c
        option secname ro

config group public_usm
        option group public
        option version usm
        option secname ro

config group private_v1
        option group private
        option version v1
        option secname rw

config group private_v2c
        option group private
        option version v2c
        option secname rw

config group private_usm
        option group private
        option version usm
        option secname rw

config view all
        option viewname all
        option type included
        option oid .1

config access public_access
        option group public
        option context none
        option version any
        option level noauth
        option prefix exact
        option read all
        option write none
        option notify none

config access private_access
        option group private
        option context none
        option version any
        option level noauth
        option prefix exact
        option read all
        option write all
        option notify all

config system
        option sysLocation      'somewhere'
        option sysContact       '[email protected]'
        option sysName          'ap-somewhere.local'
#       option sysServices      72
#       option sysDescr         'adult playground'
#       option sysObjectID      '1.2.3.4'

config exec
        option name     filedescriptors
        option prog     /bin/cat
        option args     /proc/sys/fs/file-nr
#       option miboid   1.2.3.4

config engineid
#       option engineid 'LEDE'
        option engineidtype '3'
        option engineidnic 'eth0'

#config trapcommunity 'trapcommunity'
#       option community 'public'

#config trapsink
#       option host 'nms.system.com'
#       option community 'public'
#       option port '162'

#config trap2sink
#       option host 'nms.system.com'
#       option community 'secret'
#       option port '162'

#config informsink
#       option host 'nms.sytem.com'
#       option community 'public'
#       option port '162'

#config authtrapenable 'authtrapenable'
#       option enable '1'

#config v1trapaddress 'v1trapaddress'
#       option host '1.2.3.4'

#config trapsess 'trapsess'
#       option trapsess '-v 3 -e 0x80001f88808c18d3f7b0000 -u trapuser -a MD5 -A administrator -l authPriv -x DES -X rootpasswd udp:127.0.0.1:162'

config snmpd general
        option enabled '1'
#       list network 'wan'
config exec
        option name     distro
        option prog     /usr/bin/distro
        option miboid   .1.3.6.1.4.1.2021.7890.1
config extend
        option name     interfaces
        option prog     "/bin/cat /etc/librenms/wlInterfaces.txt"
config extend
        option name     clients-wlan1
        option prog     "/etc/librenms/wlClients.sh wlan1"
config extend
        option name     clients-wlan2
        option prog     "/etc/librenms/wlClients.sh wlan2"
config extend
        option name     clients-wlan
        option prog     "/etc/librenms/wlClients.sh"
config extend
        option name     frequency-wlan1
        option prog     "/etc/librenms/wlFrequency.sh wlan1"
config extend
        option name     frequency-wlan2
        option prog     "/etc/librenms/wlFrequency.sh wlan2"
config extend
        option name     rate-tx-wlan1-min
        option prog     "/etc/librenms/wlRate.sh wlan1 tx min"
config extend
        option name     rate-tx-wlan1-avg
        option prog     "/etc/librenms/wlRate.sh wlan1 tx avg"
config extend
        option name     rate-tx-wlan1-max
        option prog     "/etc/librenms/wlRate.sh wlan1 tx max"
config extend
        option name     rate-tx-wlan2-min
        option prog     "/etc/librenms/wlRate.sh wlan2 tx min"
config extend
        option name     rate-tx-wlan2-avg
        option prog     "/etc/librenms/wlRate.sh wlan2 tx avg"
config extend
        option name     rate-tx-wlan2-max
        option prog     "/etc/librenms/wlRate.sh wlan2 tx max"
config extend
        option name     rate-rx-wlan1-min
        option prog     "/etc/librenms/wlRate.sh wlan1 rx min"
config extend
        option name     rate-rx-wlan1-avg
        option prog     "/etc/librenms/wlRate.sh wlan1 rx avg"
config extend
        option name     rate-rx-wlan1-max
        option prog     "/etc/librenms/wlRate.sh wlan1 rx max"
config extend
        option name     rate-rx-wlan2-min
        option prog     "/etc/librenms/wlRate.sh wlan2 rx min"
config extend
        option name     rate-rx-wlan2-avg
        option prog     "/etc/librenms/wlRate.sh wlan2 rx avg"
config extend
        option name     rate-rx-wlan2-max
        option prog     "/etc/librenms/wlRate.sh wlan2 rx max"
config extend
        option name     noise-floor-wlan1
        option prog     "/etc/librenms/wlNoiseFloor.sh wlan1"
config extend
        option name     noise-floor-wlan2
        option prog     "/etc/librenms/wlNoiseFloor.sh wlan2"
config extend
        option name     snr-wlan1-min
        option prog     "/etc/librenms/wlSNR.sh wlan1 min"
config extend
        option name     snr-wlan1-avg
        option prog     "/etc/librenms/wlSNR.sh wlan1 avg"
config extend
        option name     snr-wlan1-max
        option prog     "/etc/librenms/wlSNR.sh wlan1 max"
config extend
        option name     snr-wlan2-min
        option prog     "/etc/librenms/wlSNR.sh wlan2 min"
config extend
        option name     snr-wlan2-avg
        option prog     "/etc/librenms/wlSNR.sh wlan2 avg"
config extend
        option name     snr-wlan2-max
        option prog     "/etc/librenms/wlSNR.sh wlan2 max"
root@OpenWrt:/tmp#

Librenms agent files can be downloaded from here. Make sure you change permission after you upload them.

root@OpenWrt:/tmp# ls -als /etc/librenms/
     0 drwxrwxrwx    2 root     root           664 Jul 30 20:42 .
     0 drwxr-xr-x    1 root     root          1104 Jul 30 20:08 ..
     8 -rwxrwxrwx    1 root     root          4332 Jul 30 20:42 distro
     4 -rwxrwxrwx    1 root     root           860 Jul 30 20:08 wlClients.sh
     4 -rwxrwxrwx    1 root     root           516 Jul 30 20:08 wlFrequency.sh
     4 -rwxrwxrwx    1 root     root            28 Jul 30 20:09 wlInterfaces.txt
     4 -rwxrwxrwx    1 root     root           676 Jul 30 20:08 wlNoiseFloor.sh
     4 -rwxrwxrwx    1 root     root          1236 Jul 30 20:08 wlRate.sh
     4 -rwxrwxrwx    1 root     root          1146 Jul 30 20:08 wlSNR.sh
root@OpenWrt:/tmp#

Leave a reply:

Your email address will not be published.

Site Footer