Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Net-SNMP exec with OID

Posted on 2011-03-23
5
Medium Priority
?
1,103 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 1500 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

For many of us, the  holiday season kindles the natural urge to give back to our friends, family members and communities. While it's easy for friends to notice the impact of such deeds, understanding the contributions of businesses and enterprises i…
WARNING:   If you follow the instructions here, you will wipe out your VTP and VLAN configurations.  Make sure you have backed up your switch!!! I recently had some issues with a few low-end Cisco routers (RV325) and I opened a case with Cisco TA…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

609 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