Software Engineer

custom snmp stuff

· by jsnby · Read in about 1 min · (191 Words)
Computers

At work, we recently hit a minor road block in one of our monitoring applications and decided that we needed to convert some stuff to transfer data via SNMP versus other methods. I’m going to give an outline here of what I had to do to set up a simple “hello world” type query.

First off, crack open /etc/snmp/snmpd.conf and add the following line to the bottom of the file:

exec    .1.3.6.1.4.1.2021.55.71 helloworld /bin/echo hello world

Now, restart snmpd sudo /etc/init.d/snmpd restart

Now, test your new custom snmp stuff:

snmpwalk -c yourCommunityName -v1 localhost .1.3.6.1.4.1.2021.55.71

You should see something like this:

UCD-SNMP-MIB::ucdavis.55.71.1.1 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.55.71.2.1 = STRING: "helloworld"
UCD-SNMP-MIB::ucdavis.55.71.3.1 = STRING: "/bin/echo hello world"
UCD-SNMP-MIB::ucdavis.55.71.100.1 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.55.71.101.1 = STRING: "hello world"
UCD-SNMP-MIB::ucdavis.55.71.102.1 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.55.71.103.1 = ""

Now, if you want to only get the output, you need to do an snmpget instead of a walk. Notice that you have to append a .101.1…this is because that is where SNMP stores the output (see the results of the snmpwalk above):

snmpwalk -c yourCommunityName -v1 localhost .1.3.6.1.4.1.2021.55.71.101.1

You should see something like this:

UCD-SNMP-MIB::ucdavis.55.71.101.1 = STRING: "hello world"