Contacts Report

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
mkite64
Posts: 1
Joined: Fri May 03, 2013 9:04 am

Contacts Report

Post by mkite64 »

How can I generate an easy-to-read list of all contacts and what each contact gets notified for? My bosses can't read .cfg files and have requested this information. Thanks.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Contacts Report

Post by abrist »

I just scratched out a bash one liner to grep through objects.cache. It may not be what you are looking for, but here it is:

Code: Select all

cat /usr/local/nagios/var/objects.cache | grep 'host_name\|service_description\|contacts' > /tmp/contacts.
txt

The output would look like:

Code: Select all

        host_name       ebony
        service_description     Linux Raid Status checks /proc/mdstat
        contacts        neboglory
        host_name       ebony
        service_description     Web Server Port 80 check
        contacts        neboglory
        host_name       gent
        service_description     / Disk Usage
        contacts        andy,nagiosadmin,neboglory
When I run this, I get a few commands at the top, so you can clean it up a bit more with:

Code: Select all

cat /usr/local/nagios/var/objects.cache | grep 'host_name\|service_description\|contacts' |grep -v command_name > /tmp/contacts.txt
You could add strings as you see fit. For example, you can add the notification period with:

Code: Select all

cat /usr/local/nagios/var/objects.cache | grep 'host_name\|service_description\|contacts\|notification_period' |grep -v command_name > /tmp/contacts.txt
To make it a bit more readable, we will add a sed:

Code: Select all

cat /usr/local/nagios/var/objects.cache | grep 'host_name\|service_description\|contacts\|notification_period' |grep -v command_name | sed 's/host_name/\n/g' > /tmp/contacts.txt
The final output should look like:

Code: Select all

        ebony
        service_description     Linux Raid Status checks /proc/mdstat
        contacts        neboglory
        notification_period     24x7

        ebony
        service_description     Web Server Port 80 check
        contacts        neboglory
        notification_period     24x7

        gent
        service_description     / Disk Usage
        contacts        andy,nagiosadmin,neboglory
        notification_period     xi_timeperiod_24x7
Unfortunately, the contact information is saved on a per-object basis, not the other way around. I am sure someone better with sed/awk/grep could write you a one-liner for what you are actually looking for. But here it is , anyways.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked