simple chech using snmp

Andreas Ericsson ae at op5.se
Mon Oct 2 11:39:06 CEST 2006


Tom Brown wrote:
> 
>>
>> Add the following lines before the "echo $OUTPUT" line:
>>
>> if [ $EXITCODE -eq 0 ]; then
>>     echo "$OUTPUT" | grep -v CRITICAL
>>     [ $? -eq 1 ] && EXITCODE=2
>> fi
>>
>> Totally untested, but should work just dandy.
>>
>> I'm off to drink an awe inspiring amount of beer and other 
>> alcohol-based beverages now, so won't see any replies until monday.
>>
> 
> 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?

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

> ho hum - enjoy the beer
> 

Good plan. Working on it ;-)

-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

-------------------------------------------------------------------------
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