Solved

Net-SNMP exec with OID

Posted on 2011-03-23
5
1,072 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Short answer to this question: there is no effective WiFi manager in iOS devices as seen in Windows WiFi or Macbook OSx WiFi management, but this article will try and provide some amicable solutions to better suite your needs.
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 …
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
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…

726 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