autogenerating NRPE handlers for nrpe.cfg

Hari Sekhon hpsekhon at googlemail.com
Tue Feb 26 12:50:10 CET 2008


Roger wrote:
> On Fri, Feb 22, 2008 at 9:17 AM, Hari Sekhon <hpsekhon at googlemail.com 
> <mailto:hpsekhon at googlemail.com>> wrote:
>
>     Roger wrote:
>     > I have hundreds of hosts, each of which needs an npre.cfg file to
>     > reflect the true "fdisk -l" and "df -h" output of each box. 
>
>
>     >
>     > Anyone have any scripts that they've used? I'm in a bind, otherwise
>     > I'd think about writing my own...
>     If this is to get a disk check depending on what disks are available,
>     look here for a tip:
>
>     http://www.mail-archive.com/nagios-users@lists.sourceforge.net/msg11936.html
>
>
> I'm having a problem getting this sort of thing to work
>
> on monitored server (with nrpe) i have the following line in nrpe.cfg
>
> command[check_disks_proc_mount]=/usr/lib/nagios/plugins/check_disks_proc_mount
>
> In my check_disk_proc_mount script (which runs ok on its own), I have 
> something similar to 
>
> ./check_disk -w 15% -c 20% $(for x in $(/proc/mounts | awk '{print 
> $2}'); do echo -n " -p $x "; done)
>
> I run this from the command line, and I get my expected "DISK OK" 
> return value.
>
> However, I get "NRPE: Unable to read output" when I run the following 
> command from the plugins directory from my Nagios server
>
> ./check_nrpe -H (ipOfMonitoredBox) -c check_disks_proc_mount
>
> What do I need to do for this to work across NRPE like it does when 
> I'm shelled in the box?
there is an error in that shell script, the bit

$(/proc/mounts | awk '{print $2}')

is wrong. You might just change it to

$(cat /proc/mounts | awk '{print $2}')
or
$(awk '{print $2}' < /proc/mounts)

but I wouldn't recommend it, you should limit the check to real 
filesystems like ext2/ext3/reiserfs/xfs etc not things like sysfs, udev 
etc..

Try playing with this on the command line until you get it right, you 
may want to check the bash docs or ask in freenode's #bash if you're not 
strong in bash though (warning: don't ask in #bash until you've looked 
through docs or you'll get flamed if it's a simple problem to solve and 
it shows you haven't read the docs and tried sufficiently)

Also, try looking at my example again in the original link I sent you 
which does exactly what you want, all you need to do is choose the 
filesystem types you want to check.

-h

-- 
Hari Sekhon


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
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