Reporting help

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
emarmonti
Posts: 26
Joined: Fri Mar 29, 2013 10:06 am

Reporting help

Post by emarmonti »

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?
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Reporting help

Post by tgriep »

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

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);'
This will show the hosts -> contact_group information

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);'
This will show the service -> contact group information

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);'
Try them out and see if this is what you are looking for.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked