Page 1 of 1

API Config Service Ingnores check_command

Posted: Fri Aug 17, 2018 11:38 am
by mikebreed
I have over 1,000 service checks to add to Nagios so I'm using the REST API to do it. I can successfully query the API for objects and even my curl command below generates a successful new service in CCM. However, each time I do this the check_command never seems to work. In the CCM, the check command box and the args boxes are blank. When I go to apply the config, it fails since the check_command is missing.

Are there any logs that would be helpful to provide or tail?

curl -XPOST "http://xxxx/nagiosxi/api/v1/config/serv ... x&pretty=1" -d "host_name=xxxx&service_description=Disk&check_command=check_nrpe_disk_space\!15%\!10%\!/apps&check_interval=15&retry_interval=4&max_check_attempts=3&check_period=xi_timeperiod_24x7&contacts=nagiosadmin&notification_interval=5&notification_period=xi_timeperiod_24x7&applyconfig=1"​

{
"success": "Successfully added xxxx :: Disk to the system. Config applied, Nagios Core was restarted."
}

Re: API Config Service Ingnores check_command

Posted: Fri Aug 17, 2018 12:14 pm
by scottwilkerson
Are you sure you have a command defined with the name check_nrpe_disk_space?

I used your example and had the my check command was blank but args filled in, when I changed it to a command I had defined all items were filled in, I am running 5.5.2

Re: API Config Service Ingnores check_command

Posted: Fri Aug 17, 2018 12:26 pm
by mikebreed
Yes, it's in the config files as below and used in many other checks.

Code: Select all

define command {
       command_name                             check_nrpe_disk_space
       command_line                             $USER1$/check_nrpe -H $HOSTADDRESS$ -t 90 -c check_nrpe_filesystem -a $ARG1$ $ARG2$ $ARG3$
}
I'm still on 5.2.8, is there a bug that was reported for this and fixed since then?

Re: API Config Service Ingnores check_command

Posted: Fri Aug 17, 2018 1:09 pm
by scottwilkerson
This was addressed in 5.2.9
Fixed issue in config/service API section not using the check_command argument [TPS#8629] -JO
https://www.nagios.com/downloads/nagios-xi/change-log/

Re: API Config Service Ingnores check_command

Posted: Fri Aug 17, 2018 1:42 pm
by mikebreed
Thanks!

I'm not sure an upgrade is an option at this point. Are there any other methods that we could use to add a large number of services to existing hosts that already have other services configured?

Re: API Config Service Ingnores check_command

Posted: Fri Aug 17, 2018 2:12 pm
by scottwilkerson
If the services are generally the same, I would highly recommend the Bulk Host Cloning Wizard

https://assets.nagios.com/downloads/nag ... Wizard.pdf