Page 1 of 2

Configuring NRPE custom parameters

Posted: Thu Oct 04, 2012 11:43 am
by activenodes
Linux Distribution and version:
Linux nagiosxi.colo 2.6.32-279.5.1.el6.x86_64 #1 SMP Tue Aug 14 23:54:45 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

VMware Image: CentOS release 6.3 (Final)
Kernel 2.6.32-279.5.1.el6.x86_64 on an x86_64


We have a relatively large infrastructure setup in Nagios Core 3.4.1 and would like to move into the Nagios XI but with the issue we are describing here, we would like to know if our approach to resolve (what we see as an issue now) is correct or we are missing something that would make us later on have to re-do everything else back to what it was initially.


We have no problem with anything setup and configuration but rather an issue with interfacing with NRPE.
Following steps are made:

1-) Add new system with the wizard (great stuff).
2-) Enabling service: '/ Disk Usage' (fails miserably)

If we look at the monitoring settings we can see the following:
> check_nrpe!check_disk!-a '-w 20% -c 10% -p /'

Interestingly, it makes no difference what we want to put here since the NREP client has all remote-commands hardcoded at the /etc/nagios/nrpe.cfg.
Note: First main issue but not a big deal since we have control to change that.

e.g.: command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10

Instead of this one (which works almost perfect):
e.g.: command[check_users]=/usr/lib/nagios/plugins/check_users -w $ARG1$ -c $ARG2$

Our approach is not perfectly good either since it also limits us to only have these parameters accepted in each remote-client.
It would be great to do what you seem (at least we understand it like it) to do by passing a single set of parameters which are then to be 'exploded' somehow into multiple ones.


It only works (great) if we do the following at the web-interface:

[web-interface remote-command] > check_nrpe!check_disk!-a 2 10 /

or at the shell level:

[nagios-shell remote-command ]> check_nrpe -H <target-server> -c check_disk -a 20% 10% /
DISK OK - free space: / 10602 MB (58% inode=96%);| /=7453MB;15207;17108;0;19009
or
[nagios-shell remote-command ]> check_nrpe -H <target-server> -c check_disk -a '-w20% -c10% -p/'
DISK OK - free space: / 10602 MB (58% inode=96%);| /=7453MB;19009;17108;0;19009

Note: Works with and without passing the percentage as part of the parameters but for sure, it does not work if we place spaces between the switches and the parameters.
check_nrpe -H <target-server> -c check_disk -a '-w 20% -c 10% -p /'
DISK CRITICAL - 20% is not accessible: No such file or directory

We are wondering if the commands-templates should be modified to eliminate the anything but the parameters we need (without command switches and just parameters).
It's highly probable, since we are new to this system we might not be setting up the clients properly.

[remote client] > cat /etc/nagios/nrpe.cfg

log_facility=daemon
pid_file=/var/run/nagios/nrpe.pid
server_port=5666
nrpe_user=nagios
nrpe_group=nagios
allowed_hosts=127.0.0.1
dont_blame_nrpe=1
command_prefix=/usr/bin/sudo
debug=0
command_timeout=60
connection_timeout=300
include=/etc/nagios/nrpe_local.cfg
include_dir=/etc/nagios/nrpe.d/

## These commands are enabled by default (we have commented them out):
#command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10
#command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
#command[check_hda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda1
#command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z
#command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200

[remote-client] > cat /etc/nagios/nrpe_local.cfg

allowed_hosts=127.0.0.1,10.220.39.211

## These plugins do exist at /usr/lib/nagios/plugins/*:
command[check_apt]=/usr/lib/nagios/plugins/check_apt
command[check_all_disks]=/usr/lib/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -e
command[check_cron]=echo "Service: `initctl list|grep cron`"
command[check_disk]=/usr/lib/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
command[check_load]=/usr/lib/nagios/plugins/check_load -w $ARG1$ -c $ARG2$
command[check_procs]=/usr/lib/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$
command[check_rsyslog]=echo "Service: `initctl list|grep rsyslog`"
command[check_swap]=/usr/lib/nagios/plugins/check_swap -w $ARG1$ -c $ARG2$
command[check_ssh]=/usr/lib/nagios/plugins/check_ssh $ARG1$
command[check_users]=/usr/lib/nagios/plugins/check_users -w $ARG1$ -c $ARG2$
command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ -s Z

## These plugins do not exist (we had to create them but are part of the setup features):
command[check_cpu_stats]=/usr/lib/nagios/plugins/check_cpu_stats -w $ARG1$ -c $ARG2$
command[check_mem]=/usr/lib/nagios/plugins/check_mem -w $ARG1$ -c $ARG2$ -f -C
command[check_open_files]=/usr/lib/nagios/plugins/check_open_files -w $ARG1$ -c $ARG2$

Re: Configuring NRPE custom parameters

Posted: Thu Oct 04, 2012 12:13 pm
by scottwilkerson
In order to decipher this I would need to see the contents of the file in /etc/nagios/nrpe.d/ on the remote client as all the commands you have listed for the remote client are commented out.

Re: Configuring NRPE custom parameters

Posted: Thu Oct 04, 2012 12:23 pm
by activenodes
> ls -al /etc/nagios/nrpe.d/
total 8
drwxr-xr-x 2 nagios nagios 4096 May 3 11:36 .
drwxr-xr-x 3 root root 4096 Oct 4 08:33 ..

The commands reside now on the /etc/nagios/nrpe_local.cfg
They work great as long as I have modified the web-interface default command.

> cat /etc/nagios/nrpe_local.cfg
<BEGIN-OF-FILE>
######################################
# Do any local nrpe configuration here
######################################

allowed_hosts=127.0.0.1,10.220.39.211

## Nagios native-command(s):
command[check_apt]=/usr/lib/nagios/plugins/check_apt
command[check_all_disks]=/usr/lib/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -e
command[check_cron]=echo "Service: `initctl list|grep cron`"
command[check_disk]=/usr/lib/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
command[check_load]=/usr/lib/nagios/plugins/check_load -w $ARG1$ -c $ARG2$
command[check_procs]=/usr/lib/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$
command[check_rsyslog]=echo "Service: `initctl list|grep rsyslog`"
command[check_swap]=/usr/lib/nagios/plugins/check_swap -w $ARG1$ -c $ARG2$
command[check_ssh]=/usr/lib/nagios/plugins/check_ssh $ARG1$
command[check_users]=/usr/lib/nagios/plugins/check_users -w $ARG1$ -c $ARG2$
command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ -s Z

## Nagios custom-command(s):
command[check_cpu_stats]=/usr/lib/nagios/plugins/check_cpu_stats -w $ARG1$ -c $ARG2$
command[check_mem]=/usr/lib/nagios/plugins/check_mem -w $ARG1$ -c $ARG2$ -f -C
command[check_open_files]=/usr/lib/nagios/plugins/check_open_files -w $ARG1$ -c $ARG2$
<END-OF-FILE>

Should I do this to all new systems one by one or can I modify the master template instead?


ls -al $(locate nrpe)
-rw-r--r-- 1 root root 392 May 3 11:36 /etc/default/nagios-nrpe-server
-rwxr-xr-x 1 nagios nagios 2015 May 3 11:36 /etc/init.d/nagios-nrpe-server
-rw-r--r-- 1 root root 7474 Oct 4 08:05 /etc/nagios/nrpe.cfg
-rw-r--r-- 1 root root 1280 Oct 4 08:32 /etc/nagios/nrpe_local.cfg
...
-rwxr-xr-x 1 nagios nagios 42448 May 3 11:36 /usr/sbin/nrpe
...

Re: Configuring NRPE custom parameters

Posted: Thu Oct 04, 2012 12:30 pm
by scottwilkerson
So the default command in XI for check_nrpe is as follows

Code: Select all

$USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$ $ARG2$
But looking at what you have shown I am guessing you had it setup differently on your previous system and when you imported the commands it overwrote what XI had.

What does your Current check_nrpe command look like?

Re: Configuring NRPE custom parameters

Posted: Thu Oct 04, 2012 12:44 pm
by activenodes
We did not overwrote any of the new configurations with any previous ones.
It's a new setup and has nothing form the old one. That (migrating the setup) was what we wanted to do but first we are just testing the new setup.

Our 'check_nrpe' looks exactly the same.
There is nothing wrong we can see in that but rather than the web-interface sets the parameters in a way that it can't work (at least it does not for us so far) unless we modify the parameters to remove the switches and the single-quotes.

check_nrpe!check_disk!-a '-w20% -c10% -p/'

changed to:

check_nrpe!check_disk!-a 20 10 /

It works great.
Should we do the same with all the other remote-commands at the web-interface and have it set as such for next servers to be added?

Re: Configuring NRPE custom parameters

Posted: Thu Oct 04, 2012 1:23 pm
by scottwilkerson
activenodes wrote:Should we do the same with all the other remote-commands at the web-interface and have it set as such for next servers to be added?
Yes this is what I would recommend.

Re: Configuring NRPE custom parameters

Posted: Thu Oct 04, 2012 1:31 pm
by activenodes
Thank you for your reply.
Do you happen to know the answer as to why the Nagios XI default setup has a command like this:

check_nrpe!check_disk!-a '-w20% -c10% -p/'

Is this the way it's supposed to work?
Does it work for you? If so, can you tell me what am I doing wrong at my side with either the server or the agents (at the clients)?

Sincerely, Ed.
Thanks.

Re: Configuring NRPE custom parameters

Posted: Thu Oct 04, 2012 4:07 pm
by slansing
That is the way the check is shown to be defined inside Nagios, with the aliases. That is not how you would personally run it from the terminal. Are you trying to hard code values into the NRPE configuration file? Because on Nagios XI's side it is looking for a place to put the arguments you supplied, but it bounces off NRPE because there is no macro field for the arguments.

Can you show "exactly" how you have the command defined inside Nagios XI's Core Config Manager under commands?

Also a service's service management page which uses check_disk so we can see the arguments you are supplying.

Re: Configuring NRPE custom parameters

Posted: Thu Oct 04, 2012 4:14 pm
by activenodes
Nothing to do with that at all. I am trying to do exactly the opposite.
I am interested to let the NRPE client handle the parameters. As it's right now, the parameters are hardcoded within single quote to simulate a single parameter but it does not work since the agent remote-commands are hardcoded too.

All I need right now is to learn where to change this behaviour at a template base and stop getting this syntax as it's right now.
Can you help me to know where to do those changes, please?

I want the template to generate something like this:
check_nrpe!check_disk!-a 20 10 /

instead of something like this (right now it's like it):
check_nrpe!check_disk!-a '-w20% -c10% -p/'

Re: Configuring NRPE custom parameters

Posted: Thu Oct 04, 2012 4:36 pm
by scottwilkerson
If you are running one of our wizards, then expect the remote machine to have used the XI Agent installation, and the format of the commands to be the way the agent installed them.
http://assets.nagios.com/downloads/nagi ... _Agent.pdf

If you have previously deployed configurations that use a different setup that is fine, but you will need to made adjustments for that.

The wizards expect the commands to be in a certain format, for example, our Linux Wizard Expects that the following will be part of the config at the remote machine

Code: Select all

### GENERIC SERVICES ###
command[check_init_service]=sudo /usr/local/nagios/libexec/check_init_service $ARG1$
command[check_services]=/usr/local/nagios/libexec/check_services -p $ARG1$

### MISC SYSTEM METRICS ###
#command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_users]=/usr/local/nagios/libexec/check_users $ARG1$
command[check_load]=/usr/local/nagios/libexec/check_load $ARG1$
command[check_swap]=/usr/local/nagios/libexec/check_swap $ARG1$
command[check_cpu_stats]=/usr/local/nagios/libexec/check_cpu_stats.sh $ARG1$
command[check_mem]=/usr/local/nagios/libexec/custom_check_mem $ARG1$

### YUM UPDATES ###
command[check_yum]=/usr/local/nagios/libexec/check_yum

### DISK ###
command[check_disk]=/usr/local/nagios/libexec/check_disk $ARG1$
command[check_ide_smart]=/usr/local/nagios/libexec/check_ide_smart $ARG1$

### PROCESSES ###
command[check_all_procs]=/usr/local/nagios/libexec/custom_check_procs
command[check_procs]=/usr/local/nagios/libexec/check_procs $ARG1$

### OPEN FILES ###
command[check_open_files]=/usr/local/nagios/libexec/check_open_files.pl $ARG1$

### NETWORK CONNECTIONS ###
command[check_netstat]=/usr/local/nagios/libexec/check_netstat.pl -p $ARG1$ $ARG2$
as you can see the check_disk has the following format

Code: Select all

command[check_disk]=/usr/local/nagios/libexec/check_disk $ARG1$
so it is logical that the $ARG1$ is set to

Code: Select all

-w 20% -c 10% -p /
This completes the command.

You mus realize when bringing in a different core configuration the remote systems may be setup differently than XI sets them up, many people setup Core in many different ways, none of them are wrong, but we had to pick one way to work with the wizards.