Page 1 of 1

Checking mounts on a linux server

Posted: Wed Nov 30, 2011 12:56 pm
by jon.bilderback
http://exchange.nagios.org/directory/Pl ... nt/details

I'm trying to run that check on several different mountpoints, but it appears that it needs to be run on the client server. I'm not certain how to execute that script remotely, and return the results to the nagios server.

Could someone please help me with this, or direct me to the guide that explains how?

Thanks

Re: Checking mounts on a linux server

Posted: Wed Nov 30, 2011 4:29 pm
by jsmurphy
You need to install the NRPE agent on the remote server http://exchange.nagios.org/directory/Ad ... or/details

This document will guide you through the set up and how to add your own plugins http://nagios.sourceforge.net/docs/nrpe/NRPE.pdf

It's very easy once you get your head around it!

Re: Checking mounts on a linux server

Posted: Thu Dec 01, 2011 10:10 am
by jon.bilderback
Thanks for the link, however, I already have nrpe up and running on the client, and I am already doing the default checks for a Linux server.

I guess the main problem I'm having is that the check_mount script doesn't have the (typical?) -H for hostname option, and I'm not sure how to set up the command in NagiosXI, and on the client.

When I do create the command in the core config manager, the check returns an error if -H is included.

Re: Checking mounts on a linux server

Posted: Thu Dec 01, 2011 10:17 am
by mguthrie
What you'll need to do is first create the client machine's command definition, this is usually either located in /etc/nrpe.cfg or /etc/nrpe/common.cfg. It will look something like this:

(This is the command that is run locally on the client machine)
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10

Then, from the XI server, you can test this from the command-line by running

Code: Select all

cd /usr/local/nagios/libexec
./check_nrpe -H <remotehost> -c check_users
If that works ok, you can probably just clone an existing service for that host and then edit the arguments after the -c flag and enter your new command name.

Re: Checking mounts on a linux server

Posted: Thu Dec 01, 2011 11:21 am
by lmiltchev
Set your custom command on the client:

Code: Select all

# vi /usr/local/nagios/etc/nrpe.cfg
Add a command definition at the end of the file (for example):

Code: Select all

command[check_mount]=/usr/local/nagios/libexec/check_mount.sh $ARG1$
Note:
1. Make sure you have "check_mount.sh" coppied to "/usr/local/nagios/libexec" directory, and that the owner is root. Make it executable:

Code: Select all

# chmod +x /usr/local/nagios/libexec/check_mount.sh
2. You may have to change another line in "nrpe.cfg" like this:

Code: Select all

dont_blame-nrpe=1
3. Restart the daemon:

Code: Select all

# service xinetd restart
4. Test your plugin locally first - for example:

Code: Select all

# cd /usr/local/nagios/libexec
# ./check_mount.sh -p /boot -t ext3
Test your check from the Nagios server (from the command line):

# cd /usr/local/nagios/libexec

Code: Select all

# ./check_nrpe -H <target_machine_IP_address> -c check_mount -a '-p /boot -t ext3'
You should see something like this as an output:

Code: Select all

Ponto de montagem /boot está OK
Once you got it working from the command line, you can add the new service check in Nagios XI:

Go to: Core Config Manager->Monitoring->Services
Filter the results by config name and find your target machine.
Clone a service by clicking on the "Copy" Action button next to it. For example, you can "clone" the "/ Disk Usage" service.
Change the "Service description" to something that makes sense to you, for example, "check_boot".
Your "check command" should be check_nrpe, $ARG1$ should be check_mount and for $ARG2$ you can enter -a '-p /boot -t ext3'
Click on "Save" and "Apply Configuration".
Schedule an immediate check - you should get:
check_mount.png

Re: Checking mounts on a linux server

Posted: Thu Dec 01, 2011 1:11 pm
by jon.bilderback
lmiltchev,

Thanks, that appears to be going to the client for the check now.

On the client, I run the following:
./check_mount.sh -p /boot -t ext3
with the response:
Mountpoint /boot is OK

However, using the following command from the XI terminal:
./check_nrpe -H 192.168.xxx.xxx -c check_mount -a '-p /boot -t ext3'
I get the following response:
Uso: check_mount.sh -p [ponto_de_montagem OU dispositivo] -t [tipo de filesystem]

which looks like it isn't receiving the arguments correctly. Any tips on this?

Re: Checking mounts on a linux server

Posted: Thu Dec 01, 2011 5:10 pm
by lmiltchev
What happens, when on the Nagios server you run only?

Code: Select all

# ./check_nrpe -H 192.168.xxx.xxx
Did you define your command properly in the "nrpe.cfg" on the client? Did you restart the xinetd?

Re: Checking mounts on a linux server

Posted: Fri Dec 02, 2011 9:50 am
by jon.bilderback
The check NRPE from the server returns:
NRPE v2.12

I did find out how to make it work though. I had a few typoes, and a few changes, but here is the final product:


On the client, in the file /usr/local/nagios/etc/nrpe/common.cfg:
### MOUNT POINTS ###
command[check_mount]=/usr/local/nagios/libexec/check_mount.sh $ARG1$ $ARG2$

In the command inside Core Config on the XI server:
$USER1$/check_nrpe -H $HOSTADDRESS$ -c check_mount -a '-p $ARG1$ -t $ARG2$'

And now it is working! Thank you very much.

Now all I have to do is translate the ouput into english so my boss doesn't freak out.