Hi,
I created per-host monitoring using process-check-result API. So, there’s a group of host which I just need to check if it’s up or down.
Is there a way to request icinga’s API and get a list of hosts and its status?
If possible, I’d like to request icinga’s API passing a filter like ‘*.location-1.mydomain’, and get something like:
{
results: [
{
‘Host’: ‘host-1.location-1.mydomain’,
‘state’: ‘up’
}.
{
‘Host’: ‘host-2.location-1.mydomain’,
‘state’: ‘up’
}
]
}
Hello @ronanlucio
This will return your the complete object list of hosts you target : get_objects(Host).filter(h => regex("*.location-1.mydomain",h.name))
you’ll need further processing to get the status output like in your example, but you could actually map the output of this function to an other one to achieve it.