Is there a convenient way to list the statuses of all or some of the services?

I want to extract reports of the status of different subsets of services from the command line. At the moment I see a large number of the same service on different hosts which are CRITICAL, but with a variety of different problems; having a text report, ideally as a .csv file, would make it easier to analyse the extent of the different problems.

I can probably cobble something together with icinga2 console, which I can put into a script, but isn’t there something suitable available?

IIRC Icinga web does have an export function , and there is the

Oh, yes, so there is - however, it seems the csv export doesn’t include all the values I need; the long alert text is missing. And I need something to use in a script, so a web interface isn’t useful for me. Here is something I cobbled together:

icinga2 console --connect '' <<!
} | grep -E '__name|output' | paste -sd, - | while IFS=, read a b c d
> do
> echo $a
> echo $b
> echo $c
> echo $d
> done

It is still only a sketch, but it gives me some sort of output I can work on.

1 Like

This can be done using the Icinga2 API and jq:

$ curl -k -s -u root:icinga 'https://localhost:5665/v1/objects/services?filter=service.state!=ServiceOK' | jq '.results[].attrs | [.host_name, .name, .last_check_result.output] | @csv'

"\"hostname\",\"apt\",\"APT CRITICAL: 102 packages available for upgrade (100 critical updates). \""

Thx hemebond, this is probably the best way.