New Nagios Build - unable to get NRPE working

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
thetechguy
Posts: 25
Joined: Wed Feb 12, 2014 5:05 pm

Re: New Nagios Build - unable to get NRPE working

Post by thetechguy »

Once again everyone.. thank you for all of your replies.. That server that I initially tried to install the NRPE client on is still down.. however I have several other servers that I want to start monitoring using NRPE. My problem is that most of the servers in our network are old and have varied versions of CentOS, Redhat, Oracle Linux , Fedora.. etc.. Seems that this will not be cut and dry for me.. So starting with one of the servers running CentOS 4.1.2 I followed this guide to install the NRPE Client. I found a mistake in the instructions at one point and worked through it.. in any case all seems to be working fine.. If there is another /better option for this I am open to it..

Right now the CPU Load is working but the check_disk command is not. I am getting the following error.
NRPE: Command 'check_disk' not defined
I am assuming I am missing some parameters in my command. Being a newbie at this I think I need to add the following.

define service{
use generic-service
host_name myserver
service_description Drive Space
check_command check_nrpe!check_disk
}

- This where I believe I need to add some disk parameters, I do not know the proper syntax.

would it be something like this?
check_nrpe!check_disk!-w 20% !-c 10% !-p /dev/hda1

Please advise.

Thank you

Jon
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: New Nagios Build - unable to get NRPE working

Post by slansing »

Yes, it would be defined like that, it sounds like there is no check_disk command in the nrpe.cfg on the remote system, if you installed the standard nagios plugins package you should be able to set up a command to take two arguments, or hardcode it if you like, to do so, use the nrpe.cfg file's predefined commands as examples.
User avatar
millisa
Posts: 69
Joined: Thu Jan 16, 2014 11:13 pm
Location: Austin, TX
Contact:

Re: New Nagios Build - unable to get NRPE working

Post by millisa »

Following the guide you listed, that'd put your system's nrpe.cfg file at /usr/local/nagios/etc/nrpe.cfg.

You'll want to start by checking out that file.

In order for an nrpe instance to allow arguments to be sent along with the commands, you need to make sure the line:

Code: Select all

dont_blame_nrpe=1
is set to '1'. There is some risk setting this if your network isn't secure (or becomes insecure). This would allow you to create an nrpe command that you can hit from nagios with arguments like you were listing.
If you don't set that line, it'd mean you'd have to craft the command the nrpe.cfg to have all your arguments.

Covering the method that doesn't allow arguments to NRPE first:
Your nrpe.cfg on the monitored system would have something like the following
(modify the /usr/lib64/etc path to your local check_disk location on the nrpe system):

Code: Select all

dont_blame_nrpe=0
command[check_disk_hda1]=/usr/lib64/nagios/plugins/check_disk -w 20 -c 10 -p /dev/hda1
command[check_disk_hda2]=/usr/lib64/nagios/plugins/check_disk -w 20 -c 10 -p /dev/hda2
And then in nagios you'd have commands without arguments being passed to nrpe like this:

Code: Select all

define command {
        command_name    check_nrpe_disk-hda1
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_disk_hda1
}
With your service check looking like:

Code: Select all

define service{
use generic-service
host_name myserver
service_description Drive Space hda1
check_command	 check_nrpe_disk-hda1
}

You could still make your service definitions nicer by creating a nagios command definition that you could pass it a specific nrpe command to from the service definition:

Code: Select all

define command {
        command_name    check_nrpe_with_command
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
define service{
use generic-service
host_name myserver
service_description Drive Space hda1
check_command	 check_nrpe_with_command!check_disk_hda1
}
So that pretty much covers how to do the disk checks when NRPE isn't allowing arguments.


If you want NRPE to be able to accept commands so you can configure the disks you want to check at the service definition, you'd need something like this in the monitored systems nrpe.cfg:
(again, you'll need to make sure the path to check_disk is correct for your system)

Code: Select all

dont_blame_nrpe=1
command[check_disk]=/usr/lib64/nagios/plugins/check_disk -w $ARG2$ -c $ARG3$ -p $ARG1$
(nrpe needs to restart for this to take effect - that guide has your running nrpe under xinetd, so restart that when making the changes to nrpe)

and your command definition would look like:

Code: Select all

define command {
        command_name    check_nrpe_with_command
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ $ARG2$ $ARG3$ $ARG4$
#                                                                     (path) (warn) (crit)
#                                                           nrpe arg#:  1      2      3
}
(note that in this case, the 2nd argument you are passing from your service check is going to be the first argument passed to NRPE)
Your service check would look like:

Code: Select all

define service{
use generic-service
host_name myserver
service_description Drive Space hda1
check_command	 check_nrpe!check_disk!/dev/hda1!80%!90%
}
thetechguy
Posts: 25
Joined: Wed Feb 12, 2014 5:05 pm

Re: New Nagios Build - unable to get NRPE working

Post by thetechguy »

I checked my nrpe.cfg file on the remote server and it does indeed have hard codded arguments.

# The following examples use hardcoded command arguments...

command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/mapper/VolGroup00-LogVol00 - (I changed this to match my server volume)
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200

I made the above hard coded argument change after the last post however it did not change anything. I am still getting the same error.
NRPE: Command 'check_disk' not defined

I also changed my commands to the following

define service{
use generic-service
host_name gamma
service_description Drive Space
check_command check_nrpe!check_disk!-w 20% !-c 10% !-p /dev/mapper/VolGroup00-LogVol00
}

same error

any thoughts?

Thank you

Jon
User avatar
millisa
Posts: 69
Joined: Thu Jan 16, 2014 11:13 pm
Location: Austin, TX
Contact:

Re: New Nagios Build - unable to get NRPE working

Post by millisa »

The nrpe.cfg has "command[check_hda1]". Not check_disk.

Edit: I'll be more verbose, since it's my norm. Given the command in the nrpe.cfg:

Code: Select all

command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/mapper/VolGroup00-LogVol00
Your command definition would look like:

Code: Select all

define command {
        command_name    check_nrpe
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
and your service definition would look like:

Code: Select all

define service{
use generic-service
host_name gamma
service_description Drive Space hda1
check_command	 check_nrpe!check_hda1
}
thetechguy
Posts: 25
Joined: Wed Feb 12, 2014 5:05 pm

Re: New Nagios Build - unable to get NRPE working

Post by thetechguy »

Thank you millisa, I think that has helped me get closer.. I am now getting the following error..

Unknown argument
Usage:
check_disk -w limit -c limit [-W limit] [-K limit] {-p path

This is what I have changed

changed the following to the remove server nrpe.cfg file.

command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1 -(set this back to default)
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
command[check_disk]=/usr/local/nagios/libexec/check_disk -w $ARG2$ -c $ARG3$ -p $ARG1$ -(added this line)


added this service definition

Code: Select all

define service{
use                             generic-service
host_name                       gamma
service_description             Drive Space hda1
check_command                   check_nrpe!check_disk!/dev/mapper/VolGroup00-LogVol00!80%!90%
}


and added this command definition.

Code: Select all

define command {
        command_name    check_nrpe_with_command
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ $ARG2$ $ARG3$ $ARG4$
#                                                                     (path) (warn) (crit)
#                                                           nrpe arg#:  1      2      3
}

Did I miss something?

Thank you again

Jon
User avatar
lmiltchev
Former Nagios Staff
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: New Nagios Build - unable to get NRPE working

Post by lmiltchev »

I made the above hard coded argument change after the last post however it did not change anything. I am still getting the same error.
NRPE: Command 'check_disk' not defined
You don't have "check_disk" defined on the client - you have "check_hda1"...

I would change the command definition on the client from this:

Code: Select all

command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/mapper/VolGroup00-LogVol00
to this:

Code: Select all

command[check_hda1]=/usr/local/nagios/libexec/check_disk $ARG1$
Restart nrpe.

On the nagios site of things, I would change the service definition from this:

Code: Select all

define service{
use generic-service
host_name gamma
service_description Drive Space
check_command check_nrpe!check_disk!-w 20% !-c 10% !-p /dev/mapper/VolGroup00-LogVol00
}
to this:

Code: Select all

define service{
use generic-service
host_name gamma
service_description Drive Space
check_command check_nrpe!check_hda1!-a '-w 20% -c 10% -p /dev/mapper/VolGroup00-LogVol00'
}
Hope this helps.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
millisa
Posts: 69
Joined: Thu Jan 16, 2014 11:13 pm
Location: Austin, TX
Contact:

Re: New Nagios Build - unable to get NRPE working

Post by millisa »

Did you remember to set:

Code: Select all

dont_blame_nrpe=1
in the monitored system's nrpe.cfg?

NRPE won't let you pass it arguments unless you set that.
thetechguy
Posts: 25
Joined: Wed Feb 12, 2014 5:05 pm

Re: New Nagios Build - unable to get NRPE working

Post by thetechguy »

mellisa, I have dont_blame_nrpe=1 set in the remote server nrpe.cfg - still no change..

You mentioned the below earlier. I have a few questions..

nrpe needs to restart for this to take effect - that guide has your running nrpe under xinetd, so restart that when making the changes to nrpe

1. xinetd - does this service need to be restarted? I did a config reload but that did not seem to change anything.
2. Is there a way to make nrpe run as a service so that xinetd - is not effected.

Thank you

Jon
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: New Nagios Build - unable to get NRPE working

Post by slansing »

Yes, xinetd must be restarted:

Code: Select all

service xinetd restart
You can daemonize NRPE itself:

Code: Select all

/usr/local/nagios/bin/nrpe
Locked