Page 1 of 1

nagios won't load some services configs but others it will

Posted: Fri Jul 22, 2016 1:36 pm
by rreinhardt
I'm not sure what could be wrong.

I have services defined that load and work just fine, for example this works like a champ:

Code: Select all

define host {
        use                             linux-server
        host_name                       myhost
        alias                           myhost
        address                         a.b.c.d
        max_check_attempts              5
        check_period                    24x7
        notification_interval           30
        notification_period             24x7
}
define service {
        use                             generic-service
        host_name                       myhost
        service_description             PING
        check_command                   check_ping!100.0,20%!500.0,60%
}
define service {
        use                             generic-service
        host_name                      myhost
        service_description             SSH
        check_command                   check_ssh
        notifications_enabled           0
}
But, if I add any of these others into one of these server.cfg files:

then nagios will fail to reload with errors. I can run all these commands find on both the nagios core server as well as the monitored node.

Code: Select all

define service {
        use                             generic-service
        host_name                       myhost
        service_description             Disk Space
        check_command                   check_disk -w 10% -c 2% -p /
        notifications_enabled           0
}
define service {
        use                             generic-service
        host_name                       myhost
        service_description             HTTP-80
        check_command                   check_http -I a.b.c.d -p 80 -w 3 -c 5 -t 7
        notifications_enabled           0
}
define service {
        use                             generic-service
        host_name                      myhost
        service_description             Processes
        check_command                   check_procs -w 1000 -c 2000
        notifications_enabled           0
}
define service {
        use                             generic-service
        host_name                       myhost
        service_description             Swap
        check_command                   check_swap -w 50% -c 10%
        notifications_enabled           0
}
define service {
        use                             generic-service
        host_name                       myhost
        service_description             Users
        check_command                   check_users -w 10 -c 20
        notifications_enabled           0
}
The errors are:

Code: Select all

Checking objects...
 Error: Service check command 'check_disk -w 10% -c 2% -p /' specified in service 'Disk Space' for host 'myhost' not defined anywhere!
Error: Service check command 'check_http -I a.b.c.d -p 80 -w 3 -c 5 -t 7' specified in service 'HTTP-80' for host 'myhost' not defined anywhere!
Error: Service check command 'check_procs -w 1000 -c 2000' specified in service 'Processes' for host 'myhost' not defined anywhere!
 Error: Service check command 'check_swap -w 50% -c 10%' specified in service 'Swap' for host 'myhost' not defined anywhere!
Error: Service check command 'check_users -w 10 -c 20' specified in service 'Users' for host 'myhost' not defined anywhere!

{...}

 Total Warnings: 0
Total Errors:   5
 ***> One or more problems was encountered while running the pre-flight check...
 Check your configuration file(s) to ensure that they contain valid
directives and data defintions.  If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version.  Make sure to read
the HTML documentation regarding the config files, as well as the
 nagios.service: control process exited, code=exited status=8
Reload failed for LSB: Starts and stops the Nagios monitoring server.
Thanks,
Rob

Re: nagios won't load some services configs but others it wi

Posted: Fri Jul 22, 2016 1:44 pm
by tgriep
The services that have errors, you are missing the exclamation point ! between the command and the arguments. Try adding those and that should fix it for you.

Re: nagios won't load some services configs but others it wi

Posted: Fri Jul 22, 2016 2:34 pm
by rreinhardt
I thought using the macro substitution was optional not required.

Since they're required, can you point me to a doc that has the specific macro substitution syntax for each plug-in defined?

Some of these have a lot of command line options, and some of those won't be used. If I can't specify the actual flag telling the command what param I'm specifying, how does it know which one is which? How do I make sure that it does?

Re: nagios won't load some services configs but others it wi

Posted: Fri Jul 22, 2016 3:33 pm
by rreinhardt
What is the proper syntax of that? Is it this?

check_disk!-w 10% -c 2% -p /

because that's not working either.

I've also tried:

this

check_disk!-w 10%!-c 2%!-p /!

and this

check_disk!10%!2%/

all give the same error.

By the way, I'm running Nagios Core 4.1.1 and NRPE 2.15 on Centos 7

Re: nagios won't load some services configs but others it wi

Posted: Mon Jul 25, 2016 11:14 am
by tgriep
I think those commands are missing from the commands.cfg file and if you can post that file, we can review it and let you know the changes that have to be done.
Also, most of the example checks you posted are for checking the Nagios server itself and not remote servers, do you want to check the disk, procs, swap, users on a remote server using NRPE?
If so, take a look at this document that explains how to do that.
https://assets.nagios.com/downloads/nag ... e/NRPE.pdf