Hello,
I have a need to generate a report that will tell me which contact is alerted given a service and/or a host. I'm not sure what the best method would be to retrieve this information.
Considering that:
- Our Nagios XI implementation is complicated, in that there are many different service and host templates
- We have many different contact groups tied to different templates (in order to notify different teams at different times of the day, such as workhours vs afterhours vs 24x7)
- most hosts and services use templates, however there are a number that don't use templates and have a contact group directly connected to them because they things that were added ad-hoc, or things that require more custom settings.
So apart from awk'ing and grepping files in /usr/local/nagios/etc/hosts and /usr/local/nagios/etc/services, contacts.cfg and contactgroups.cfg, I'm not quite sure how to organize all of this information.
Would anyone have a recommendation on how best I might be able to do this?
Reporting help
Re: Reporting help
I have some MYSQL queries that you can run to gather the host / service and the contact / contact groups assigned to them.
They only show that is setup in the running configuration.
This will show the hosts -> contact information
This will show the hosts -> contact_group information
This will show the service -> contact information
This will show the service -> contact group information
Try them out and see if this is what you are looking for.
They only show that is setup in the running configuration.
This will show the hosts -> contact information
Code: Select all
/usr/bin/mysql -u root -pnagiosxi -e 'SELECT nagios.nagios_hosts.host_object_id,nagios.nagios_host_contacts.host_id,nagios.nagios_host_contacts.contact_object_id,nagios.nagios_contacts.contact_object_id,nagios_hosts.alias,nagios_hosts.display_name,nagios_contacts.alias,nagios_contacts.email_address FROM ((nagios.nagios_hosts INNER JOIN nagios.nagios_host_contacts ON nagios.nagios_hosts.host_id = nagios.nagios_host_contacts.host_id) INNER JOIN nagios.nagios_contacts ON nagios.nagios_host_contacts.contact_object_id = nagios.nagios_contacts.contact_object_id);'Code: Select all
/usr/bin/mysql -u root -pnagiosxi -e 'SELECT nagios.nagios_hosts.host_object_id,nagios.nagios_host_contactgroups.host_id,nagios.nagios_host_contactgroups.contactgroup_object_id,nagios.nagios_contactgroups.contactgroup_object_id,nagios.nagios_hosts.alias,nagios_hosts.display_name,nagios_contactgroups.alias FROM ((nagios.nagios_hosts INNER JOIN nagios.nagios_host_contactgroups ON nagios.nagios_hosts.host_id = nagios.nagios_host_contactgroups.host_id) INNER JOIN nagios.nagios_contactgroups ON nagios.nagios_host_contactgroups.contactgroup_object_id = nagios.nagios_contactgroups.contactgroup_object_id);'This will show the service -> contact information
Code: Select all
/usr/bin/mysql -u root -pnagiosxi -e 'SELECT nagios.nagios_services.service_object_id,nagios.nagios_service_contacts.service_id,nagios.nagios_service_contacts.contact_object_id,nagios.nagios_contacts.contact_object_id,nagios_services.display_name,nagios_contacts.alias,nagios_contacts.email_address FROM ((nagios.nagios_services INNER JOIN nagios.nagios_service_contacts ON nagios.nagios_services.service_id = nagios.nagios_service_contacts.service_id) INNER JOIN nagios.nagios_contacts ON nagios.nagios_service_contacts.contact_object_id = nagios.nagios_contacts.contact_object_id);'Code: Select all
/usr/bin/mysql -u root -pnagiosxi -e 'SELECT nagios.nagios_services.service_object_id,nagios.nagios_service_contactgroups.service_id,nagios.nagios_service_contactgroups.contactgroup_object_id,nagios.nagios_contactgroups.contactgroup_object_id,nagios_services.display_name,nagios_contactgroups.alias FROM ((nagios.nagios_services INNER JOIN nagios.nagios_service_contactgroups ON nagios.nagios_services.service_id = nagios.nagios_service_contactgroups.service_id) INNER JOIN nagios.nagios_contactgroups ON nagios.nagios_service_contactgroups.contactgroup_object_id = nagios.nagios_contactgroups.contactgroup_object_id);'Be sure to check out our Knowledgebase for helpful articles and solutions!