set / retrieve parents, templates via api call
Posted: Mon Apr 24, 2017 2:13 pm
It looks like the api docs are not exhaustive for fields that can be set on a host. I have two hosts, laka.noc and lono.noc. I would like lono to be a parent of laka. Laka otherwise has all it's parameters configured correctly, so I force post it with just the parents parameter (which appears to be undocumented):
[lukas@nagiosxi-dev ~]$ curl -k -XPOST "https://nagiosxi-dev.noc.harvard.edu/na ... h&pretty=1" -d "host_name=laka.noc.harvard.edu&parents=lono.noc.harvard.edu&force=1&applyconfig=1"
{
"success": "Successfully added laka.noc.harvard.edu to the system. Config applied, Nagios Core was restarted."
}
When I look at laka in the ccm, I can see it has a parent of lono, but if I http/get the host, I do not see parentage.
[lukas@nagiosxi-dev ~]$ curl -k -XGET "https://nagiosxi-dev.noc.harvard.edu/na ... arvard.edu"
{
"hostlist": {
"recordcount": "1",
"host": {
"@attributes": {
"id": "509"
},
"instance_id": "1",
"host_name": "laka.noc.harvard.edu",
"is_active": "1",
"config_type": "1",
"alias": "laka.noc.harvard.edu",
"display_name": "laka.noc.harvard.edu",
"address": "laka.noc.harvard.edu",
"check_interval": "5",
"retry_interval": "1",
"max_check_attempts": "2",
"first_notification_delay": "0",
"notification_interval": "5",
"passive_checks_enabled": "1",
"active_checks_enabled": "1",
"notifications_enabled": "1",
"notes": "this is a test from Luke and Mike",
"notes_url": "",
"action_url": "",
"icon_image": "",
"icon_image_alt": "",
"statusmap_image": ""
}
}
}
Is there a way to programmatically retrieve the list of parents of a host?
Similarly, is it possible to get a list of templates that are applied (via the use= parameter when posting a host/service)?
thanks,
-Luke
[lukas@nagiosxi-dev ~]$ curl -k -XPOST "https://nagiosxi-dev.noc.harvard.edu/na ... h&pretty=1" -d "host_name=laka.noc.harvard.edu&parents=lono.noc.harvard.edu&force=1&applyconfig=1"
{
"success": "Successfully added laka.noc.harvard.edu to the system. Config applied, Nagios Core was restarted."
}
When I look at laka in the ccm, I can see it has a parent of lono, but if I http/get the host, I do not see parentage.
[lukas@nagiosxi-dev ~]$ curl -k -XGET "https://nagiosxi-dev.noc.harvard.edu/na ... arvard.edu"
{
"hostlist": {
"recordcount": "1",
"host": {
"@attributes": {
"id": "509"
},
"instance_id": "1",
"host_name": "laka.noc.harvard.edu",
"is_active": "1",
"config_type": "1",
"alias": "laka.noc.harvard.edu",
"display_name": "laka.noc.harvard.edu",
"address": "laka.noc.harvard.edu",
"check_interval": "5",
"retry_interval": "1",
"max_check_attempts": "2",
"first_notification_delay": "0",
"notification_interval": "5",
"passive_checks_enabled": "1",
"active_checks_enabled": "1",
"notifications_enabled": "1",
"notes": "this is a test from Luke and Mike",
"notes_url": "",
"action_url": "",
"icon_image": "",
"icon_image_alt": "",
"statusmap_image": ""
}
}
}
Is there a way to programmatically retrieve the list of parents of a host?
Similarly, is it possible to get a list of templates that are applied (via the use= parameter when posting a host/service)?
thanks,
-Luke