Page 1 of 1

Export Contacts and Contact Groups

Posted: Thu Dec 14, 2017 9:59 am
by jkinning
Is there an easy way to export Contacts and Contact Groups to a csv file to audit? It would be nice to also include the systems that these contacts and contact groups belong to so you can see everything from a nice spreadsheet. Is any of this easy to do?

Re: Export Contacts and Contact Groups

Posted: Thu Dec 14, 2017 2:36 pm
by kyang
We don't have a feature to do something like this in XI.

It's not as pretty, but I think grepping for that information in the objects.cache might be something?

Code: Select all

 grep -A 1 "define contact" /usr/local/nagios/var/objects.cache

Code: Select all

grep -A 1 "define contact" /usr/local/nagios/var/objects.cache > /tmp/contact.csv 
Into a csv.

Does this help?

Re: Export Contacts and Contact Groups

Posted: Thu Dec 14, 2017 3:21 pm
by jkinning
This looks like it might work for the contacts. Anyway to get the email or SMS number for each contact? I know I am asking alot. :D
What about for Contact Groups to see what contacts are listed in each group?

Then along hose lines get the contacts or contact groups that are assigned for each host/services. If I can't get this data in a csv file just being able to view this information might be enough.

Re: Export Contacts and Contact Groups

Posted: Thu Dec 14, 2017 3:29 pm
by kyang
To show the contacts in a contact group, try changing it to 3. This should show the members in a contact_group and it's alias.
You probably see the pattern now. The number adds more lines.

Same thing is to send all this to a csv for example --> > /tmp/contact.csv

For email or SMS, you would have to increase the number, but this will show all of the contact info.

Code: Select all

grep -A 9 "define contact" /usr/local/nagios/var/objects.cache
This shows the output below.

Code: Select all

define contact {
        contact_name    xi_default_contact
        alias   Default Contact
        service_notification_period     xi_timeperiod_none
        host_notification_period        xi_timeperiod_none
        service_notification_options    n
        host_notification_options       n
        service_notification_commands   xi_service_notification_handler
        host_notification_commands      xi_host_notification_handler
        email   root@localhost