Solved

Net-SNMP exec with OID

Posted on 2011-03-23
5
1,038 Views
Last Modified: 2012-06-21
Hello, experts,

I was ordered some small program as

 - Using Net-SNMP and "exec" in snmpd.conf
 - answer for "snmpget ..snip.. .xxx.123"
 - above 123 is pid(process id) and variable
 - exec program can be any language(sh,perl,c)
 - exec calling program works with pid
 - exec calling program returns like
   ".xxx.123 = 28765 Integer" (28765 is example)

I can program with C, but I'm newbie in snmp.
I read documents about snmpd.conf, but it says about only fixed parameter.

I need experts help, Thanks
0
Comment
Question by:NobMiwa
  • 3
  • 2
5 Comments
 
LVL 9

Expert Comment

by:svs
ID: 35206973
'pass' is better suited for this than 'exec'
0
 
LVL 9

Accepted Solution

by:
svs earned 500 total points
ID: 35207097
something like this should work
#!/bin/sh

OIDBASE=.1.3.6.1.4.1.789

CMD=$1
OID=$2

if [ -z "$OID" ]; then
        echo "this is a snmpd 'pass' plugin"
        exit 1
fi

if [ $CMD != "-g" ]; then
        exit
fi

PID=${OID##.1.3.6.1.4.1.789.}
RESULT=`cat /proc/$PID/cmdline | wc -c`

echo $OID
echo integer
echo $RESULT

Open in new window

0
 

Author Comment

by:NobMiwa
ID: 35208524
Thanks svs,

But still don't know about how to write pass statement in snampd,conf

I wrote like this,

pass .1.3.6.1.4.1.789 /bin/sh /usr/local/passtest.sh

And try

# snmpwalk -v 2c -c private localhost .1.3.6.1.4.1.789.999
SNMPv2-SMI::enterprises.789.999 = No Such Instance currently exists at this OID

Please advice .. (T_T)
0
 

Author Comment

by:NobMiwa
ID: 35209227
Hi, svs,

I searched Google and got a code attached.
and now it works !

Thanks for advice.

#!/bin/sh
if [ "$1" = "-g" ]
then
echo .1.3.6.1.2.1.1.1.0
echo string
echo test2 $1 $2
fi
if [ "$1" = "-n" ]
then
if [ "$2" = ".1.3.6.1.2.1.1.1" ]
then
echo .1.3.6.1.2.1.1.1.0
echo string
echo testNext2
fi
fi

Open in new window

0
 

Author Closing Comment

by:NobMiwa
ID: 35209236
Great advice at this moment
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

How to set-up an On Demand, IPSec, Site to SIte, VPN from a Draytek Vigor Router to a Cyberoam UTM Appliance. A concise guide to the settings required on both devices
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now