What is the easiest way to obtain a report of the current services that includes:
1) service name
2) service description
3) service state (i.e., active or not)
4) associated hosts
5) notification contacts
6) other info is helpful but not necessary
I've looked in the objects.cache file and all the info I need is there but each service is defined for each host so with the 65 services we have there are 360 "define service" entries in the file.
Thanks for any help -- Tom
Obtaining configuration
Re: Obtaining configuration
Hey Tom,
You could grep for that information. I'll try to work on something when I can.
I'm not exactly sure of the fields you wanted from the objects.cache. With the list, you provided up above?
Could you give the exact names of each field from the objects.cache file?
You could grep for that information. I'll try to work on something when I can.
I'm not exactly sure of the fields you wanted from the objects.cache. With the list, you provided up above?
Could you give the exact names of each field from the objects.cache file?
Code: Select all
service name --> service description
service description -- xx
service state --> active_checks_enabled
associated hosts --> host_name
notification contacts --> contacts
Re: Obtaining configuration
if you could give me these 4 fields (service_description|host_name|contacts|contact_groups), separated by the pipe char (|) for each "define service" that would be perfect. Thanks very much for your help -- Tom
Re: Obtaining configuration
Here's a nice neat new-line delimited version of that thing:
It's worth mentioning that objects.cache only contains the configuration directives that are absolutely necessary; IE it won't "auto fill" unecessary directives. If there's no contacts or contact_groups assigned/inherited (bequeathed?) to a service, they won't show up.
The first 4 results only have a contact_groups directive in their config file. The last 4 results have both a contacts and contact_groups directive in their config file. You could do more clever things with sed than I have to get it into CSV (or pipe-delimited format) I imagine.
Code: Select all
[root@capra_nag services]# sed -e '/define service/,/}/!d' /usr/local/nagios/var/objects.cache | grep 'host_name\|service_description\|contact_groups\|contacts' | sed 's/host_name/\n\thost_name/'
host_name PRODDELPHISCRIPTS
service_description DataMart
contact_groups admins
host_name PRODDELPHISCRIPTS
service_description Graylog
contact_groups admins
host_name PRODDELPHISCRIPTS
service_description Logstash
contact_groups admins
host_name PRODDELPHISCRIPTS
service_description Process Monitor
contact_groups admins
host_name PRODHERMES1
service_description Hermes Front-end on 7777
contacts nagiosadmin
contact_groups admins
host_name PRODHERMES2
service_description Hermes Front-end on 7777
contacts nagiosadmin
contact_groups admins
host_name PRODHERMES3
service_description Hermes Front-end on 7777
contacts nagiosadmin
contact_groups admins
The first 4 results only have a contact_groups directive in their config file. The last 4 results have both a contacts and contact_groups directive in their config file. You could do more clever things with sed than I have to get it into CSV (or pipe-delimited format) I imagine.
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
Re: Obtaining configuration
Yes it is exactly what I needed. Thanks for the quick turnaround -- Tom