1

I am attempting to extend snmp to return number of a given process

This is the tool, saved at /usr/bin/count_proc.sh

#!/bin/bash
ps aux | awk '
BEGIN { c=0 }
/processname$/ { c=c+1 }
END { print $c }'

in my snmpd.conf, I have the following line:

extend .1.3.6.1.4.1.8072.9999.1 count_proc /usr/bin/count_proc.sh

However, I am not able to retrieve the result of this command with this OID. When I run a snmp query for this OID, the result is:

Value: (Snmp No Such object)

If I run traverse the snmp tree, I finally see something, but its strange... "Next OID" is the name of my tool, and not numeric at all.

OID: .1.3.6.1.4.1.8072.9999.1.2.1.2.9.99.111.117.110.116.95.102.119.100
Next OID: /usr/bin/count_proc.sh
Value: 1

And finally, I will see the value I am expecting.

OID: .1.3.6.1.4.1.8072.9999.1.3.1.1.9.99.111.117.110.116.95.102.119.100
Value: 13

But this is not the OID I expected to query to find the output. I will also find the output on several other OIDs.

Is this working as intended, or am I missing something important here?

3

Personally I use extend without OID, like:

extend count_proc /usr/bin/count_proc.sh

The OID generated by snmp is simple, the result is:
NET-SNMP-EXTEND-MIB::nsExtendOutput1Line.”count_proc”

The OID is :
1.3.6.1.4.1.8072.1.3.2.3.1.1.10.99.111.117.110.116.95.112.114.111.99

Explanation : 10 : number of character in "count_proc" 99 : ASCII decimal value of 'c' 111 : ASCII decimal value of 'o' 117 : ASCII decimal value of 'u' 110 : ASCII decimal value of 'n' 116 : ASCII decimal value of 't' 95 : ASCII decimal value of '_' 112 : ASCII decimal value of 'p' 114 : ASCII decimal value of 'r' 111 : ASCII decimal value of 'o' 99 : ASCII decimal value of 'c'

So you can easily retrieve the OID programatically.

0

Probably This link can help you in "extend" naming convention

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.