Page 1 of 1
command that works on the command line,but how in a cfg.file
Posted: Wed Mar 27, 2019 9:43 am
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
Re: command that works on the command line,but how in a cfg.
Posted: Wed Mar 27, 2019 11:18 am
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
Re: command that works on the command line,but how in a cfg.
Posted: Wed Mar 27, 2019 3:23 pm
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.
Re: command that works on the command line,but how in a cfg.
Posted: Wed Mar 27, 2019 4:15 pm
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.
Re: command that works on the command line,but how in a cfg.
Posted: Wed Mar 27, 2019 4:42 pm
by welbp00
Thnx npolovenko.
I will read the pdf, and configure the files.
I will let you know the progress.
Regards,
Paul.
Re: command that works on the command line,but how in a cfg.
Posted: Thu Mar 28, 2019 4:16 pm
by npolovenko
@welbp00, Sounds good, keep us updated.
Re: command that works on the command line,but how in a cfg.
Posted: Thu Apr 04, 2019 9:08 am
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.
Re: command that works on the command line,but how in a cfg.
Posted: Thu Apr 04, 2019 3:21 pm
by npolovenko
@welbp00, Glad you figured it out! Feel free to open new threads when something else comes up.