Create custom SNMP OID in Linux

This guide was written using CentOS 6.5. I describe how to create a custom script to obtain the 1 minute load average on a LInux system and expose that script in SNMP to be polled by an SNMP poller like Nagios or Solarwinds.

STEP 1. create the 1 minute load average script.

vim /usr/sbin/
awk '{print $1}' /proc/loadavg

STEP 2. Update the snmpd.conf file to extend SNMP.

vim /etc/snmp/snmpd.conf
extend 1minloadavg /usr/sbin/

STEP 3. Restart SNMPD

service snmpd restart


snmpwalk -v2c -c public localhost NET-SNMP-EXTEND-MIB::nsExtendObjects | grep 1minloadavg

NET-SNMP-EXTEND-MIB::nsExtendCommand."1minloadavg" = STRING: /usr/sbin/
NET-SNMP-EXTEND-MIB::nsExtendArgs."1minloadavg" = STRING:
NET-SNMP-EXTEND-MIB::nsExtendInput."1minloadavg" = STRING:
NET-SNMP-EXTEND-MIB::nsExtendCacheTime."1minloadavg" = INTEGER: 5
NET-SNMP-EXTEND-MIB::nsExtendExecType."1minloadavg" = INTEGER: exec(1)
NET-SNMP-EXTEND-MIB::nsExtendRunType."1minloadavg" = INTEGER: run-on-read(1)
NET-SNMP-EXTEND-MIB::nsExtendStorage."1minloadavg" = INTEGER: permanent(4)
NET-SNMP-EXTEND-MIB::nsExtendStatus."1minloadavg" = INTEGER: active(1)
NET-SNMP-EXTEND-MIB::nsExtendOutput1Line."1minloadavg" = STRING: 0.08
NET-SNMP-EXTEND-MIB::nsExtendOutputFull."1minloadavg" = STRING: 0.08
NET-SNMP-EXTEND-MIB::nsExtendOutNumLines."1minloadavg" = INTEGER: 1
NET-SNMP-EXTEND-MIB::nsExtendResult."1minloadavg" = INTEGER: 0
NET-SNMP-EXTEND-MIB::nsExtendOutLine."1minloadavg".1 = STRING: 0.08

STEP 5. Grab the named OID you wish to monitor and use snmptranslate to translate the named OID to a numerical value.

[root@mysql01p ~] snmptranslate -On NET-SNMP-EXTEND-MIB::nsExtendOutputFull.\"1minloadavg\"

The OID can then be entered into your favorite SNMP poller. In this case I use Solarwinds Universal Device Poller. However, there are many open source solutions like Nagios which also support this.


One thought on “Create custom SNMP OID in Linux

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s