Linux Net-SNMP agent can be extended using a PEN (private Enterprise Number) on /etc/snmp/snmpd.conf (man snmpd.conf
for details)
# from the man page: extend [MIBOID] NAME PROG ARGS
extend .1.3.6.1.4.1.32473 2 /tmp/snmp.sh
snmp.sh is a simple bash script that will echo the passed argument or current date otherwise with some weird exit codes
#!/bin/bash
if [ -n "$1" ]; then
echo "$1"
exit 51
fi
/bin/date '+%F %T'
exit 37
Running snmpwalk
on that OID
snmpwalk -c public -v 2c 127.0.0.1 SNMPv2-SMI::enterprises.32473
Returns
SNMPv2-SMI::enterprises.32473.1.0 = INTEGER: 1
SNMPv2-SMI::enterprises.32473.2.1.2.1.50 = STRING: "/tmp/snmp.sh"
SNMPv2-SMI::enterprises.32473.2.1.3.1.50 = ""
SNMPv2-SMI::enterprises.32473.2.1.4.1.50 = ""
SNMPv2-SMI::enterprises.32473.2.1.5.1.50 = INTEGER: 5
SNMPv2-SMI::enterprises.32473.2.1.6.1.50 = INTEGER: 1
SNMPv2-SMI::enterprises.32473.2.1.7.1.50 = INTEGER: 1
SNMPv2-SMI::enterprises.32473.2.1.20.1.50 = INTEGER: 4
SNMPv2-SMI::enterprises.32473.2.1.21.1.50 = INTEGER: 1
SNMPv2-SMI::enterprises.32473.3.1.1.1.50 = STRING: "2018-06-07 20:53:44"
SNMPv2-SMI::enterprises.32473.3.1.2.1.50 = STRING: "2018-06-07 20:53:44"
SNMPv2-SMI::enterprises.32473.3.1.3.1.50 = INTEGER: 1
SNMPv2-SMI::enterprises.32473.3.1.4.1.50 = INTEGER: 37
SNMPv2-SMI::enterprises.32473.4.1.2.1.50.1 = STRING: "2018-06-07 20:53:44"
Trying to interpret the numbers
32473
is the PEN reserved for examples and documentation that can be used locally for testing purposes
50
is the decimal value of the ascii character 2
, the NAME.
Using -Of
or-Os
with snmpwalk
or snmptranslate
to provide an explanation of the tree does not work and output shows the plain numbers
snmptranslate -OS -Td SNMPv2-SMI::enterprises.32473.2.1.1.50
Result
SNMPv2-SMI::enterprises.32473.2.1.1.50
enterprises OBJECT-TYPE
-- FROM SNMPv2-SMI
::= { iso(1) org(3) dod(6) internet(1) private(4) enterprises(1) 32473 2 1 1 50 }
What the objects (numbers) after 32473 mean?
Those object numbers can be explained by comparing with the
snmpwalk
result of the another form of theextend
option that does not use a PEN OIDRunning a
snmpwalk
to get symbolic namesResult:
Adding
-On
to get the numeric output givesThe numeric output for the PEN exercise is
Now we can compare both exercises line by line by keeping the common part at the end and adding some convenience formatting
Ex1:
.1.3.6.1.4.1.32473. 1.0 = INTEGER: 1
Ex2:
.1.3.6.1.4.1.8072.1.3.2.1.0 = INTEGER: 1
Doing the same for all entries and comparing line by line: