Currently, my OIDs branch from Net-SNMP using extend
, which results in an OID like this:
SNMPv2-SMI::enterprises.8072.1.3.2.4.1.2.1.49.1258
or without the MIB:
.1.3.6.1.4.1.8072.1.3.2.4.1.2.1.49.1258
8072 is Net-SNMP,
49 is the decimal value of an ASCII "1" (an arbitrary name I gave my extension), and
1258 is a 'leaf' on my root OID (49).
Now that I have a PEN, how do I go about making my OID tree under my PEN so that I can execute an snmpwalk
that displays:
.1.3.6.1.4.1.<MyPEN>.<MyOIDTree>
OS: Linux (Raspbian)
-Good-
Specify an OID in the extend
command (in snmpd.conf) like so:
extend [OID] <extName> </dir/binary> </dir/script>
The OID is optional, however, omitting it will cause the Net-SNMP PEN to be used by default.
In my case, my extend
looks like this:
extend .1.3.6.1.4.1.<myPEN> SQL /bin/sh /usr/sbin/MyScript.sh
This produces the following output:
.1.3.6.1.4.1.[PEN redacted].4.1.2.3.83.81.76.1258 = STRING: "My Data"
This is much closer to the desired structure since it is now extending from a custom PEN, though one is now faced with trimming off the .4.1.2.3
and the .83.81.76
(resulting from the extension name 'SQL').
If anyone knows how to remove those, post it as a new answer!
-Better-
Use the pass
command:
pass .1.3.6.1.4.1.PEN /bin/sh /home/pi/net-snmp/local/shellCode
Shell code example: passtest
Output:
.1.3.6.1.4.1.PEN.1.0 = STRING: "Hello World!"
.1.3.6.1.4.1.PEN.2.1.2.1 = INTEGER: 9
.1.3.6.1.4.1.PEN.2.1.3.1 = OID: .1.3.6.1.4.1.PEN.99
.1.3.6.1.4.1.PEN.3.0 = Timeticks: (363136200) 42 days, 0:42:42.00
.1.3.6.1.4.1.PEN.4.0 = IpAddress: 127.0.0.1
.1.3.6.1.4.1.PEN.5.0 = Counter32: 9
.1.3.6.1.4.1.PEN.6.0 = Gauge32: 9
This appears to solve both issues, however I am unsure of the extent of its capabilities in comparison to a 'proper' OID tree installation.
-Best- (Complete Solution)
Register OIDs using a MIB...