command that works on the command line,but how in a cfg.file

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.
Locked
welbp00
Posts: 50
Joined: Fri Mar 08, 2019 5:48 am

command that works on the command line,but how in a cfg.file

Post by welbp00 »

Hi,
i am trying to make nagios monitoor filesystems on sevaral remote linux-servers.

On the command line(from the nagios-server) this works fine.

nagios-server:

/usr/lib64/nagios/plugins/check_nrpe -H on7p0021 -t 30 -c check_disk -a '-w 20% -c 10% -R /'

On the remote linux-server:

nrpe.cfg:

command[check_disk]=/usr/lib64/nagios/plugins/check_disk $ARG1$

But is use a services.cfg file, that looks like this:

define service {
use generic-service
host_name on7p0021
check_interval 300
service_description Check Disk Space Root
check_command check_disk!check_root
check_interval 15
retry_interval 1

It doesn't seem to be working. Nothing in the gui, no error calls in the logs..

I also use a basic.cfg, that looks like this:

define command{
command_name check_disk
command_line /usr/lib64/nagios/plugins/check_nrpe -H '$HOSTADDRESS$' -c check_disk -t 300 -a '$ARG1$' '$ARG2$' '$ARG3$' '$ARG4$'
}

What am i doing wrong...?? Please Help.
Regards Paul
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: command that works on the command line,but how in a cfg.

Post by npolovenko »

Hello, @welbp00. This is what your command looks like compiled.
/usr/lib64/nagios/plugins/check_nrpe -H hostaddress_here -c check_disk -t 300 -a 'check_root'
In your service check, you're calling the check_disk command and after ! you have "check_root", meaning that the first $ARG1$ is going to be check_root. ! signs are used to separate arguments.

This is what I recommend using instead:
define command{
command_name check_nrpe
command_line /usr/lib64/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -t 300 -c $ARG1$ $ARG2$
}
define service {
use generic-service
host_name on7p0021
check_interval 300
service_description Check Disk Space Root
check_command check_nrpe!check_disk! -a '-w 20% -c 10% -R /'
check_interval 15
retry_interval 1
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
welbp00
Posts: 50
Joined: Fri Mar 08, 2019 5:48 am

Re: command that works on the command line,but how in a cfg.

Post by welbp00 »

Hello npolovenko, many thnx for your reply.

But i still don't get it to work. I am sure i am doing something wrong....
After the adjustments made given by you, i still don't see anything appear in the nagios gui. The logging is showing no errors.
Here is some more info.

i have a:

010.linux.basic.cfg

define command{
command_name check_disk
command_line /usr/lib64/nagios/plugins/check_nrpe -H '$HOSTADDRESS$' -t 300 -c $ARG1$ $ARG2$
}

-------------------------------------
and a 020.linux.hostgroups.cfg

and a 030.linux.hosts.cfg

and a 040.linux.services.cfg

containing:

define service {
use generic-service
host_name {{ db2Servers.db2primary1.name }}
check_interval 300
service_description Check Disk Space Root
check_command check_nrpe!check_disk! -a '-w 20% -c 10% -R /'
check_interval 15
retry_interval 1
}

What command line must i put in the nrpe.cfg?

Hope you can help this newbee out...

Thnx, and regards.

Paul.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: command that works on the command line,but how in a cfg.

Post by npolovenko »

@welbp00, You shouldn't use single quotes around $HOSTADDRESS$ because that will force nagios to import the string literal instead of the actual host name. Please change this:
define command{
command_name check_disk
command_line /usr/lib64/nagios/plugins/check_nrpe -H '$HOSTADDRESS$' -t 300 -c $ARG1$ $ARG2$
}
To this:
define command{
command_name check_disk
command_line /usr/lib64/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -t 300 -c $ARG1$ $ARG2$
}

Also, this is not going to work:
host_name {{ db2Servers.db2primary1.name }}
You need to create host definitions for each host. You can find examples of host definitions in this tutorial:
https://assets.nagios.com/downloads/nag ... e/NRPE.pdf
Section: " Create host and service definitions"
Then you need to create service definitions. You can find examples right after host examples in the same article.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
welbp00
Posts: 50
Joined: Fri Mar 08, 2019 5:48 am

Re: command that works on the command line,but how in a cfg.

Post by welbp00 »

Thnx npolovenko.

I will read the pdf, and configure the files.

I will let you know the progress.

Regards,

Paul.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: command that works on the command line,but how in a cfg.

Post by npolovenko »

@welbp00, Sounds good, keep us updated.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
welbp00
Posts: 50
Joined: Fri Mar 08, 2019 5:48 am

Re: command that works on the command line,but how in a cfg.

Post by welbp00 »

Got it working. Something about using two hosts.cfg... A collegua helped me and we worked it out.

Lack of experience was the problem.

Learning every day :)

Thnx for the support, you may close this topic.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: command that works on the command line,but how in a cfg.

Post by npolovenko »

@welbp00, Glad you figured it out! Feel free to open new threads when something else comes up.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked