Question on setting up my own check

Trond Hasle Amundsen t.h.amundsen at usit.uio.no
Wed Oct 20 15:34:47 CEST 2010


Marc Powell <lists at xodus.org> writes:

> 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}'`

Or... set PATH before doing anything else, e.g.

  #!/bin/bash
  PATH=/bin:/sbin:/usr/bin:/usr/sbin
  export PATH
  [...rest of script...]

This will enhance readability wrt. using full paths everywhere.

Cheers,
-- 
Trond H. Amundsen <t.h.amundsen at usit.uio.no>
Center for Information Technology Services, University of Oslo

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