simple chech using snmp

Thomas Sluyter nagios at kilala.nl
Mon Oct 2 11:58:06 CEST 2006


Yay, debugging! \o/

Could be handy if we move this off-list, unless no-one objects to us  
handling this through the list.


>> bha! end of the script now looks like this
>>
>> ### FINALLY... RETRIEVING THE VALUES ###
>>
>> EXITCODE=`$SNMPWALK -v 1 -c $COMMUNITY $HOST $STATUS`
>> [ $DEBUG -gt 0 ] && echo "Retrieve exit code is $EXITCODE" >>  
>> $DEBUGFILE
>>
>> OUTPUT=`$SNMPWALK -Ovq -v 1 -c $COMMUNITY $HOST $STRING`
>> [ $DEBUG -gt 0 ] && echo "Retrieve status message is: $OUTPUT" >>
>> $DEBUGFILE
>>
>> if [ $EXITCODE -eq 0 ]; then
>>    echo "$OUTPUT" | grep -v CRITICAL
>>    [ $? -eq 1 ] && EXITCODE=2
>> fi
>>
>> echo $OUTPUT
>> exit $EXITCODE
>>
>> but when it runs i get this
>>
>> ../libexec/retrieve_custom_snmp: line 84: [: -eq: unary operator  
>> expected
>> "CRITICAL emcpowera has 2 dead, 2 alive"
>>
>
> Urgh. My bad. What does EXITCODE contain when you run it in debug  
> mode?

It should contain the exact same value it contains when not running  
in debug mode: the exit code for the Nagios script being run through  
SNMP exec.

Could you tell me what exactly is contained on line 84 in your case?  
Because in the version of the script up on my website, line 84 is  
part of the Nagios "help" text.

I think I -should- look into the whole "-Ovq" bit a little bit  
though. I think the $EXITCODE may benefit from this as well...

If I find some time this afternoon, I'll start digging...


> (on a side-note, whoever names a variable containing textual output  
> "EXITCODE" should be shot)

Yes, that would be me thank you... What kind of gun would you prefer?  
I would like to smoke a pipe before being executed, though. Mind?

But before you pull that trigger, would you please go back just a wee  
a bit and read my docu on what $EXITCODE contains? Why yes, it -does-  
in fact contain the exit code of the Nagios script that was run on  
the client side! OMG! Let me quote the bit in question:

# Output:
# The exit code is the exit code retrieved from OID.100.0.
# The output string is the string retrieved from OID.101.1.

/me puts on a blind fold.

Any suggestions for a variable name change are more than welcome. And  
I guess I -could- elaborate the docu a bit more. Expect a newer  
version, some time this afternoon.

>> ho hum - enjoy the beer
>>
> Good plan. Working on it ;-)

Right about now, I'm wishing I had a nice, cold bottle of "Lambiek  
Kriek" in my desk drawer.

Cheers,


Thomas



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
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