apan snmp plugin problem

Tim Stoddard testoddard at ualr.edu
Fri Aug 27 15:22:00 CEST 2004


Actually no.  In the snmp.sh plugin that comes with APAN a system call 
to check_snmp is used.  No warning or critical value are given to the 
check_snmp plugin therefore it always returns a code of 1 (or warning 
condition).  The APAN plugin is supposed to silently ignore the warning 
and go about it's business.  However the code as distributed seems to 
detect the warning and error out.

Original code from snmp.sh APAN plugin.

                VALUE=`$PLUGINSDIR/check_snmp -H $HOST -C $COMM -m none 
-o $OID`
                STATUS=$?
                COUNTER=`echo $VALUE|awk '{print $NF}'`
                if [ $STATUS -gt 0 ]; then
                        RETVAL=2
                        RETSTR=`echo "$VALUE"|head -1`
                        ERR=1
                        break
                fi
                TEMPL="$TEMPL:$DSNAME"


If I modify the script to look like the following and it will work 
flawlessly.

                VALUE=`$PLUGINSDIR/check_snmp -H $HOST -C $COMM -m none 
-o $OID`
#  force a good return value
#               STATUS=$?
                STATUS=0
                COUNTER=`echo $VALUE|awk '{print $NF}'`
                if [ $STATUS -gt 0 ]; then
                        RETVAL=2
                        RETSTR=`echo "$VALUE"|head -1`
                        ERR=1
                        break
                fi
                TEMPL="$TEMPL:$DSNAME"

How is this script working for other people using Nagios/APAN.  I do not 
understand why I had to modify this?



-- 

Timothy Stoddard

Lawrence, Lynne wrote:

> I suspect that the change you made did not fix your problem.  The 
> '{print $NF}' is in single quotes, as such your variable would not be 
> replaced.  In awk, $NF is the number of fields in the line, so the 
> print statement will print the last field on the line, fields being 
> separated by whitespace.
>  
> Hope this helps,
>  
> Lynne Lawrence
>
>     -----Original Message-----
>     From: nagios-users-admin at lists.sourceforge.net
>     [mailto:nagios-users-admin at lists.sourceforge.net]On Behalf Of Tim
>     Stoddard
>     Sent: Thursday, August 26, 2004 10:20 AM
>     To: HUDRY Olivier
>     Cc: nagios-users at lists.sourceforge.net
>     Subject: Re: [Nagios-users] apan snmp plugin problem
>
>     I got the same problem when I installed APAN on Nagios.  I ended
>     up hacking the snmp.sh that come with APAN.  One of the shell
>     variables was not getting set correctly, so I ended up creating a
>     work around.  The $NF variable in the following line needs to 4,
>     however I cannot find where it gets set.  This $VALUE is the
>     output line that APAN has to parse.   The fourth value is the
>     actual  snmp  value APAN is looking for. 
>
>
>                     COUNTER=`echo $VALUE|awk '{print $NF}'`
>
>     I added the following and APAN began to work like champ. 
>
>     #It would seem the $NF variable is not getting set
>     NF=4
>     #echo "$NF"
>                     STATUS=$?
>                     COUNTER=`echo $VALUE|awk '{print $NF}'`
>
>     My shell scripting is not great.  I am sure someone else could
>     pretty this up.  Hope this helps.
>
>-- 
>
>Timothy Stoddard
>    
>
>
>     HUDRY Olivier wrote:
>
>>     hi,
>>      
>>     I'm trying to monitor some disk usage with apan-sql
>>     i've created:
>>     - service in nagios
>>     - serviceext
>>     - database record with apanconf
>>      
>>     and i'can't get info from this plug-in.
>>      
>>     the message in nagios is:
>>      
>>     (Return code of 127 is out of bounds - plugin may be missing) 
>>      
>>     thanks for your help
>>      
>>     -----------------------------------------------------
>>                   Olivier HUDRY
>>     Technicien d'exploitation - Pôle E&A
>>                o.hudry at gip-cps.fr <mailto:o.hudry at gip-cps.fr>
>>     -----------------------------------------------------
>>      
>
>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20040827/5fda49fc/attachment.html>


More information about the Users mailing list