Question on setting up my own check

Marc Powell lists at xodus.org
Wed Oct 20 15:08:55 CEST 2010


On Oct 19, 2010, at 2:20 PM, steve f wrote:

> Hello All,
> 
> I have the following script created to check free space on a remote legacy box via rsh. 
> 
> used=`sudo rsh $1 df -v |grep starlite6 | head -1 | awk '{print $4}'`
> free=`sudo rsh $1 df -v |grep starlite6 | head -1 | awk '{print $5}'`

Beyond just good programming practice, always use full paths to external programs within your scripts. $PATH may not be what you expect it to be, especially when being run by the nagios daemon which has a more restrictive environment.

# (paths may be different on your system)
used=`/usr/bin/sudo /usr/bin/rsh $1 /bin/df -v | /bin/grep starlite | /usr/bin/head -1 | /usr/bin/awk '{print $4}'`

(chop...)

>       echo "OK. Free Space: `sudo rsh $1 df -v |grep starlite6 |head -1 | awk
> '{print $5}'`B, $percent%"

You already have this value as $free; why not just use it instead of rsh'ing again?

>       echo "Warning. Free Space: `sudo rsh $1 df -v |grep starlite6 | head -1 |
> awk '{print $5}'`B, $percent%"

Same...

>       echo "Critical. Free Space: `sudo rsh $1 df -v |grep starlite6 | head -1 |
>  awk '{print $5}'`B, $percent%"

Same...

>  If I run this from the command line, I get the following response:
> 
> /usr/local/nagios/libexec # ./check_starlite_size LEGACYBOX 70 80
> Critical. Free Space: 51090B, 2%

Bad test. Never test the functionality of a plugin as root. root can rsh into the box but can the nagios user? Depending on how your command{} definition is set up, you probably want to make sure that the value 'LEGACYBOX' is exactly the same as what you have defined as the 'address' in the host{} definition.

> if nagios runs the script , I keep getting an unknown result on the central server ( distributed environment btw) 
> from nagios.log on central server:
> [1287511053] PASSIVE SERVICE CHECK: strXXXXsa;Starlite Size;3;Unknown
> 
> I assume that the issue is an incorrect format for the send_nsca file but cant figure out how to set it up correctly.

nsca has nothing to do with it since you aren't using it. Verify that the nagios user can rsh into the box and test your plugin as the nagios user, not root.


------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
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