Capturing perf data from check_snmp

James Whittington James.Whittington at vc3.com
Fri Apr 15 15:16:39 CEST 2005


Thank you Scott and Erwin for your input.

Erwin was right, I had seen the information on developing plugins and
what it said about return codes previously.
I thought since I was using an existing plugin and just adding to the
output the return codes would be in tact. The return codes from the
plugin were getting trapped in the perl wrapper.

I still don't know how to catch a return code from the plugin, but by
doing some string comparisons on the plugin output I can generate a
return code from the perl wrapper.

Thanks again for your help, you input made me a happy guy when this
stuff started working around midnight :<).
 

James Whittington



-----Original Message-----
From: nagios-users-admin at lists.sourceforge.net
[mailto:nagios-users-admin at lists.sourceforge.net] On Behalf Of
Erwin.Mascardo at intelsat.com
Sent: Thursday, April 14, 2005 4:05 PM
To: nagios-users at lists.sourceforge.net
Subject: RE: [Nagios-users] Capturing perf data from check_snmp

You're both working too hard here by trying to parse the output from the
snmpget command. Keep reading...

>-----Original Message-----
>From: scott_yem at agilent.com [mailto:scott_yem at agilent.com] 
>Sent: Thursday, 14 April, 2005 12:56
>To: nagios-users at lists.sourceforge.net
>Subject: RE: [Nagios-users] Capturing perf data from check_snmp


>You may need to check the output you get with the snmpget command.  I
had a
similar thing working on an older
>version and when I upgraded I had to track that down.  I found the
output
from the snmpget command changed and I had
>to incorporate that into my logic.
 
>Scott Yem



>>From: nagios-users-admin at lists.sourceforge.net
[mailto:nagios-users-admin at lists.sourceforge.net] On Behalf Of James
Whittington
>>Sent: Thursday, April 14, 2005 9:50 AM
>>To: nagios-users at lists.sourceforge.net
>>Subject: [Nagios-users] Capturing perf data from check_snmp
 
>>I'm using Nagios version 1.3 with Plugins version 1.4-2 on a debian
sarge
system.
>>I am using perfparse to capture performance data to mysql.
>>I am trying to capture an rfinput value of a wireless device through
the
check_snmp plugin and write it to a mysql
>>db for reporting.
 
>>Since check_snmp does not currently write performance data in the
output I
was trying to write a simple perl script
>>to use check_snmp but add the performance data to the output.
>>To make a long story short my simple perl script is adding performance
data to the output and perfparse is picking
>>it up, but I noticed that the service status in Nagios is always "OK"
even
when the Status Information says
>>otherwise.

<snip screen snap> 
 
>>Here's how it looks through check_snmp
>>./check_snmp -H10.0.10.12
-oSNMPv2-SMI::enterprises.2378.1.1.2.1.2.80.1.1.3.5 -w 22:50
>>SNMP WARNING - *51*

What you're not seeing here is the return code from check_snmp. It's
returning a value of 1, which corresponds to WARNING.
 
>>Here's the modified output from the perl script that triggers perfdata
but
kills status funtionallity in Nagios.  
>>./check_rfinput3 -H10.0.10.12
>>SNMP WARNING - *54* neg-dbm|rf-input=54
 
>>Here's the very very basic script that did the damage.
>>/usr/lib/nagios/plugins# more check_rfinput3
>>#!/usr/bin/perl
>>if ($ARGV[0] eq "") {
>>       print "Hostaddress required\n";
>>        print "ie.. script.pl 123.123.123.123\n";
>>}else{
>>        $HOSTADDRESS = $ARGV[0];
>>        $HOSTADDRESS =~ s/-H//;
>>$RFINPUT = `/usr/lib/nagios/plugins/check_snmp -H$HOSTADDRESS
-oSNMPv2-SMI::enterprises.2378.1.1.2.1.2.80.1.1.3.5 -w 22:48 -c 20:55 -u
neg-dbm`;
>>$RFRAW = $RFINPUT;
>>$RFRAW =~s/[^0-9]//g;
>>chomp($RFINPUT);
>>print "$RFINPUT|rf-input=$RFRAW";
>>}

You need to grab the return value from check_snmp. It will be 0, 1, 2,
or 3.
The wrapper script needs to return the same value in order to have
Nagios
process it.

>>I even tried to modify the check_snmp source code which fixed the
status
info but did not get me perfdata for some
>>reason.
>>./nagios-plugins-1.4/plugins/check_snmp -H10.0.10.12  -oSNMPv2-SMI::
enterprises.2378.1.1.2.1.2.80.1.1.3.5 -w 22:60
 54
>>SNMP OK - 54|SNMP= 54
 
>>The output from the perl wrapper looks pretty much the same and the
output
from plugins that have perf data built
>>in to them so I am at a loss as to why it doesn't work.
>>I'm not a not a perl of nagios guru yet, so I figured I would through
this
out to the list to see how other folks
>>many have solved this problem already.

Read up on how to write custom plugins:
http://nagiosplug.sourceforge.net/developer-guidelines.html
 
>>Thanks for any guidance you all may provide.
 

############################################################

Building on 40 Years of Leadership - As a global communications leader
with 40 years of experience, Intelsat helps service providers, 
broadcasters, corporations and governments deliver information and
entertainment anywhere in the world, instantly, securely and reliably.

############################################################
This email message is for the sole use of the intended
recipient(s) and may contain confidential and privileged
information.  Any unauthorized review, use, disclosure or 
distribution is prohibited.  If you are not the intended 
recipient, please contact the sender by reply email and 
destroy all copies of the original message.  Any views 
expressed in this message are those of the individual 
sender, except where the sender specifically states them 
to be the views of Intelsat, Ltd. and its subsidiaries.
############################################################


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when
reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list