[ale] need help with nagios plugin

Chuck Payne terrorpup at gmail.com
Thu Dec 2 14:29:31 EST 2010


On Thu, Dec 2, 2010 at 2:08 PM, Michael H. Warfield <mhw at wittsend.com> wrote:
> I'm not totally clear on what you are doing (maybe why you aren't seeing
> more help) but I can see one potential problem...
>
> On Thu, 2010-12-02 at 11:59 -0500, Chuck Payne wrote:
>> Guys,
>>
>> I need a bit of help, right not I am very upset about the lack of help
>> I got from the #nagios chat room. I need help with my bash script.
>> Sorry, I am still a bit of nood on script. I am having an issue with
>> the syntax.
>>
>> I have a custom plugin I wrote...see at the bottom. It works I am
>> getting output, but no prefdata. I have for a link that explain how to
>> get perfdata, http://nagiosplug.sourceforge.net/developer-guidelines.html#AEN201
>> 2.6
>>
>>
>> label'=value[UOM];[warn];[crit];[min];[max]
>>
>> The output I get is....
>>
>> Total number of Tengu rules are at 8762
>>
>> I know base of the line about I should be able to get this
>>
>> tengu=8762; 9000;10000;0
>>
>> My problem is how to I tell my script this is perfdata do I do some
>> thing this...
>
>> perfdata () { tengu=$r;$w;$c;0}
>
> The above line will not work unless it's quoted.  The semi ';' is a
> command delimiter so that's the equivalent of the the following
> commands:
>
> tengu=$r
> $w
> $c
> 0
>
> Which I'm sure is not what you intend.
>
> I suspect that what you are trying to do would be this:
>
> perfdata () { tengu="$r;$w;$c;0"}
>
> Or maybe I'm misreading what you're trying to do.
>
>> Is that right?
>
> Is which right?  The line above or the script below?
>
>> Chuck
>
> Regards,
> Mike
>
>> ======================================
>>
>> #!/bin/sh
>>
>> count () { rm /tmp/tencount ; if [ tengubin =
>> '/usr/local/magi/bin/tengu' ] ; then /usr/local/magi/bin/tengu
>> countnolines >> /tmp/tencount ; else /usr/local/magi/bin/fyre
>> countnolines >> /tmp/tencount; fi ; cat /tmp/tencount ;}
>>
>> r=$(count)
>>
>> #test critical
>> #r=12000
>>
>> #test warning
>> #r=9005
>>
>> w=9000
>>
>> c=10000
>>
>>
>> if [ "$r" -gt "$c" ]
>> then
>>       echo "Total number of Tengu rules are $r and is CRITICAL"
>>       RETVAL=2
>> elif [ "$r" -gt "$w" ]
>> then
>>       echo "Warning: Total number of Tengu rules are at $r"
>>       RETVAL=1
>> else
>>       echo "Total number of Tengu rules are at $r"
>>       RETVAL=0
>> fi
>> echo $RETVAL
>>
>>
>>
>>
>> --
>> -----------------------------------------
>> Discover it! Enjoy it! Share it! openSUSE Linux.
>> -----------------------------------------
>> openSUSE -- en.opensuse.org/User:Terrorpup
>> openSUSE Ambassador/openSUSE Member
>> skype,twiiter,identica,friendfeed -- terrorpup
>> freenode(irc) --terrorpup/lupinstein
>>
>> Have you tried SUSE Studio? Need to create a Live CD,  an app you want
>> to package and distribute , or create your own linux distro. Give SUSE
>> Studio a try. www.susestudio.com.
>>
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org
>> http://mail.ale.org/mailman/listinfo/ale
>> See JOBS, ANNOUNCE and SCHOOLS lists at
>> http://mail.ale.org/mailman/listinfo
>>
>
> --
> Michael H. Warfield (AI4NB) | (770) 985-6132 |  mhw at WittsEnd.com
>   /\/\|=mhw=|\/\/          | (678) 463-0932 |  http://www.wittsend.com/mhw/
>   NIC whois: MHW9          | An optimist believes we live in the best of all
>  PGP Key: 0x674627FF        | possible worlds.  A pessimist is sure of it!
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>
>
I got it. Check it out. If you do these  \| $perfdata it give the perfdata. .

#!/bin/sh

count () { rm /tmp/tencount ; if [ tengubin =
'/usr/local/magi/bin/tengu' ] ; then /usr/local/magi/bin/tengu
countnolines >> /tmp/tencount ; else /usr/local/magi/bin/fyre
countnolines >> /tmp/tencount; fi   ; cat /tmp/tencount ;}

r=$(count)

#test critical
#r=12000

#test warning
#r=9005

w=9000

c=10000

perfdata='tengu='$r';'$w';'$c';0'

if [ "$r" -gt "$c" ]
then
       echo "Total number of Tengu rules are $r and is CRITICAL" \| $perfdata
       RETVAL=2
elif [ "$r" -gt "$w" ]
then
       echo "Warning: Total number of Tengu rules are at $r" \| $perfdata
       RETVAL=1
else
        echo "Total number of Tengu rules are at $r" \| $perfdata
        RETVAL=0
fi

exit $RETVAL


-- 
-----------------------------------------
Discover it! Enjoy it! Share it! openSUSE Linux.
-----------------------------------------
openSUSE -- en.opensuse.org/User:Terrorpup
openSUSE Ambassador/openSUSE Member
skype,twiiter,identica,friendfeed -- terrorpup
freenode(irc) --terrorpup/lupinstein

Have you tried SUSE Studio? Need to create a Live CD,  an app you want
to package and distribute , or create your own linux distro. Give SUSE
Studio a try. www.susestudio.com.



More information about the Ale mailing list