Issue 1:
Attempting to add a new host through the API. The response says successful, but the host is not created in the DB or the config files. I think it is due to the remote DB we have setup and the API is trying to use the local DB and not the remote DB. Does the API use the /usr/local/nagiosxi/html/config.inc.php or some other configuration file? If I use the same exact curl command against a NagiosXI server which has a local DB, it works correctly.
- Nagios Version: 5.2.2 and 5.2.3 (Mixed Environment. All servers will be on 5.2.3, in a few weeks)
- Using admin API key
Issue 2:Command Used:
curl -XPOST "http://<Nagios Server>/nagiosxi/api/v1/config/host?apikey=<API Key>&pretty=1" -d "host_name=testapihostapply&address=127.0.0.1&check_command=check_ping\!3000,80%\!5000,100%&max_check_attempts=2&check_period=24x7&contacts=nagiosadmin¬ification_interval=5¬ification_period=24x7&applyconfig=1"
{
"success": "Successfully added testapihostapply to the system. Config applied, Nagios Core was restarted."
}
Using the create a new host API command, it requires a number of fields. I want to use the template instead of forcing the values on each host. Is there a way to do that?
- Nagios Version: 5.2.2 and 5.2.3 (Mixed Environment. All servers will be on 5.2.3, in a few weeks)
- Using admin API key
curl -XPOST "http://<Nagios Server>/nagiosxi/api/v1/config/host?apikey=<API Key>&pretty=1" -d "host_name=testapihostapply&address=127.0.0.1&use=testhosttemplate&applyconfig=1"
{
"error": "Missing required variables",
"missing": [
"max_check_attempts",
"check_period",
"notification_interval",
"notification_period",
"contacts OR contact_groups"
]
}
Host Template:
define host {
name testhosttemplate
alias testhosttemplate
check_command check-host-alive!!!!!!!!
initial_state u
max_check_attempts 5
check_interval 4
retry_interval 5
active_checks_enabled 1
check_period 24x7_with_sunday_maintenance
flap_detection_options u,
process_perf_data 1
contact_groups nocontact
notification_interval 0
notification_period 24x7_with_sunday_maintenance
notification_options d,u,r,f,s,
register 0
}