Page 1 of 1

CFG Host Definition problems

Posted: Mon Mar 23, 2020 1:56 pm
by Opa114
Hi there,

i noticed a strange behaviour with my config files.

First i have this CFG-File to monitor some windows machines:
define host {
use windows-server
host_name myServer
alias myServer
address IP
}

define service {
use generic-service
host_name myServer
service_description NSClient++ Version
check_command check_nt!CLIENTVERSION
}


Second one with modified "check_ncpa" (from the example in the Documentation):
define host {
host_name myServer
address IP
check_command check_ncpa!-t 'TOKEN' -P 5693 -M system/agent_version
max_check_attempts 5
check_interval 5
retry_interval 1
check_period 24x7
contacts nagiosadmin
notification_interval 60
notification_period 24x7
notifications_enabled 1
register 1
}

define service {
host_name myServer
service_description CPU Usage
check_command check_ncpa!-t 'TOKEN' -P 5693 -M cpu/percent -w 20 -c 40 -q 'aggregate=avg'
max_check_attempts 5
check_interval 5
retry_interval 1
check_period 24x7
notification_interval 60
notification_period 24x7
contacts nagiosadmin
register 1
}


Till today we have used "check_nt" with "NSClient++". So because "NSClient++" ist very old and did not get updates we decided to use "NCPA" from Nagios on out Clients and check with "check_ncpa". So i replaced the "check_nt" commands with the matching "check_ncpa" commands, but after that the service will not restart and exited with an error. When i change the mian nagios.cfg to laod the old config with "check_nt" used the service is starting without any problems. Strange thing...

Then i check the Documentation. There is mentioned that the red marked fields are needed! but that is a little bit wrong, because i can start it without using all the required parameters, like this config. This config start without any problem. Only "hostname", "address" and "max_check_attempts" is needed, but the Documentation mentions a lot more..

define host {
host_name myServer
address IP
#check_command check_ncpa!-t 'TOKEN' -P 5693 -M system/agent_version
max_check_attempts 5
#check_interval 5
#retry_interval 1
#check_period 24x7
#contacts nagiosadmin
#notification_interval 60
#notification_period 24x7
#notifications_enabled 1
#register 1
}


So what are the problems here? Why did my first modifief config not start but my second one? And what about the required fields problem?

Thanks a lot!

Re: CFG Host Definition problems

Posted: Mon Mar 23, 2020 5:39 pm
by Box293
Opa114 wrote: Then i check the Documentation. There is mentioned that the red marked fields are needed! but that is a little bit wrong, because i can start it without using all the required parameters, like this config. This config start without any problem. Only "hostname", "address" and "max_check_attempts" is needed, but the Documentation mentions a lot more..
This is because you are using templates to layer configs, i.e. use windows-server. These options are required however they don't need to exist in each layer of the configs/templates as they build a final config. If the final config is missing a directive then yes it will fail.
Opa114 wrote:So i replaced the "check_nt" commands with the matching "check_ncpa" commands, but after that the service will not restart and exited with an error.
What was the error?

Did you put the check_ncpa command definition in your configs as well? I did not see this in your configs.

Re: CFG Host Definition problems

Posted: Tue Mar 24, 2020 3:34 am
by Opa114
oh yeah i found the mistake. I had forgotten to create the host group windows-servers. I accidentally deleted this group.

Re: CFG Host Definition problems

Posted: Tue Mar 24, 2020 7:27 am
by scottwilkerson
Opa114 wrote:oh yeah i found the mistake. I had forgotten to create the host group windows-servers. I accidentally deleted this group.
Great!

Locking thread