SNMP/Examples/Example 3:Extending SNMP
From ImageStream Router Documentation
< SNMP | Examples
Revision as of 19:22, 12 June 2008 by RichardJune (Talk | contribs)
- SNMP can be extended by inserting the output of a command into the tree. This allows you to write scripts to fetch any information you like and monitor that data similar to interface statistics, RAM usage, and CPU load.
- This example feeds voltage, CPU fan speed, and CPU temperature information into the SNMP tree at OID .1.3.6.1.4.1.2021.54. First save the following to /root/bin/snmpsensors.
#!/bin/bash Start sensors >/dev/null 2>&1 sensors -c /usr/share/etc/sensors.conf >/dev/null 2>&1 fields="$(sensors -c /usr/share/etc/sensors.conf|grep -vi isa |cut -f 2 -d : | awk '{print $1}')" for f in $fields ; do echo $f 1 '*' | dc done Stop sensors>/dev/null 2>&1
Then run chmod 755 /root/bin/snmpsensors
Last, add exec .1.3.6.1.4.1.2021.54 sensors /root/bin/snmpsensors
to your SNMP configuration and restart SNMP.
The output of snmpwalk looks like this:
rjune@rjune-desktop:~$ snmpwalk -v 2c -c public gw01 .1.3.6.1.4.1.2021.54 UCD-SNMP-MIB::ucdavis.54.1.1 = INTEGER: 1 UCD-SNMP-MIB::ucdavis.54.2.1 = STRING: "sensors" UCD-SNMP-MIB::ucdavis.54.3.1 = STRING: "/root/bin/snmpsensors" UCD-SNMP-MIB::ucdavis.54.100.1 = INTEGER: 0 UCD-SNMP-MIB::ucdavis.54.101.1 = STRING: "1.76" UCD-SNMP-MIB::ucdavis.54.101.2 = STRING: "3.5" UCD-SNMP-MIB::ucdavis.54.101.3 = STRING: "4.8" UCD-SNMP-MIB::ucdavis.54.101.4 = STRING: "12.16" UCD-SNMP-MIB::ucdavis.54.101.5 = STRING: "5.26" UCD-SNMP-MIB::ucdavis.54.101.6 = STRING: "3.34" UCD-SNMP-MIB::ucdavis.54.101.7 = STRING: "8035" UCD-SNMP-MIB::ucdavis.54.101.8 = STRING: "35" UCD-SNMP-MIB::ucdavis.54.101.9 = STRING: "1.75" UCD-SNMP-MIB::ucdavis.54.102.1 = INTEGER: 0 UCD-SNMP-MIB::ucdavis.54.103.1 = ""