Obtaining configuration

This board serves as an open discussion and support collaboration point for Nagios XI. NOTE: Nagios XI customers should use the Customer Support forum to obtain expedited support.

Obtaining configuration

Postby tcjr2 » Fri Feb 09, 2018 2:06 pm

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
tcjr2
 
Posts: 9
Joined: Thu Feb 01, 2018 4:05 pm

Re: Obtaining configuration

Postby kyang » Fri Feb 09, 2018 3:26 pm

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?
Code: Select all
service name --> service description
service description -- xx
service state --> active_checks_enabled
associated hosts --> host_name
notification contacts --> contacts
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
kyang
Support Tech
 
Posts: 1790
Joined: Tue Jul 25, 2017 3:35 pm

Re: Obtaining configuration

Postby tcjr2 » Sat Feb 10, 2018 8:35 pm

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
tcjr2
 
Posts: 9
Joined: Thu Feb 01, 2018 4:05 pm

Re: Obtaining configuration

Postby mcapra » Mon Feb 12, 2018 10:13 am

Here's a nice neat new-line delimited version of that thing:

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


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.
Former Nagios employee
http://www.mcapra.com/
User avatar
mcapra
 
Posts: 3291
Joined: Thu May 05, 2016 3:54 pm

Re: Obtaining configuration

Postby kyang » Mon Feb 12, 2018 10:50 am

Thanks for the help @mcapra!

This is definitely nice.

tcjr2, Does this answer your question?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
kyang
Support Tech
 
Posts: 1790
Joined: Tue Jul 25, 2017 3:35 pm

Re: Obtaining configuration

Postby tcjr2 » Tue Feb 13, 2018 9:13 am

Yes it is exactly what I needed. Thanks for the quick turnaround -- Tom
tcjr2
 
Posts: 9
Joined: Thu Feb 01, 2018 4:05 pm

Re: Obtaining configuration

Postby kyang » Tue Feb 13, 2018 10:04 am

Yes, thanks @mcapra!

tcjr2, Did you have any more questions or are we okay to lock this up?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
kyang
Support Tech
 
Posts: 1790
Joined: Tue Jul 25, 2017 3:35 pm


Return to Nagios XI

Who is online

Users browsing this forum: Bing [Bot] and 10 guests