Page 1 of 1

disabled notifications

Posted: Tue Jun 04, 2013 10:00 am
by paul.jobb
Is there anyway to identify service/host checks where the notifications that have been disabled? i.e. a report of some sort.

Re: disabled notifications

Posted: Tue Jun 04, 2013 2:34 pm
by lmiltchev
If you go to Reports->Event Log, you will be able to see hosts/services which had notifications enabled/disabled. If you use Enterprise edition, you can obtain more information (user, IP Address, etc.) by going to: Admin->Audit Log.

Re: disabled notifications

Posted: Wed Jun 05, 2013 7:58 am
by BanditBBS
I run a script(in cron) every Monday and Thursday that emails me a list. Let me grab that and post it for you.

Re: disabled notifications

Posted: Wed Jun 05, 2013 8:01 am
by BanditBBS
Script:

Code: Select all

#!/bin/sh
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either Version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This script was designed to run the two awk scripts host_status.awk and service_status.awk
# and send an email if anything is returned.
#
DATE=`date +%c`
HOST=`/bin/cat /usr/local/nagios/var/status.dat | /usr/local/nagios/var/host_status.awk`
SERVICE=`/bin/cat /usr/local/nagios/var/status.dat | /usr/local/nagios/var/service_status.awk`
MAIL="/bin/mail -s"
SUBJECT="Disabled Nagios notifications *** $DATE"
BODY="$HOST $SERVICE"
RCPT="[email protected]"

if [[ -n $HOST || -n $SERVICE ]]
then
/usr/bin/printf "%b" "$BODY" | $MAIL "$SUBJECT" $RCPT
else
echo "Nothing is disabled..."
fi
host_status.awk:

Code: Select all

#!/bin/awk -f
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# This script will parse nagios's status.log file usually located in /usr/local/nagios/var/
# or /usr/local/groundwork/nagios/var/ (if using groundwork) and is supposed to look for all hosts
# that have notifications turned off.  This can be useful to remind a busy sysadmin
# of the services disabled in the middle of the night that he/she may have forgotten.
#
BEGIN { header=0;
        FS="=";
}

/^[[:space:]]*info {[[:space:]]*$/ {
        codeblock="info";
}

/^[[:space:]]*programstatus {[[:space:]]*$/ {
        codeblock="program";
}

/^[[:space:]]*hoststatus {[[:space:]]*$/ {
        codeblock="host";
        host_name="";
        notifications_enabled="";
}

/^[[:space:]]*servicestatus {[[:space:]]*$/ {
        codeblock="service";
}

/^[[:space:]]*host_name=/ {
        host_name=$2;
}

/^[[:space:]]*notifications_enabled=/ {
        notifications_enabled=$2;
}

/^[[:space:]]*}[[:space:]]*$/ {
                if (codeblock=="host" && notifications_enabled=="0") {
                        if (header==0) {
                                print "\n**************************************\nThe following hosts have notifications disabled:\n"
                                header=1;
                        }
                        print host_name "\n";
        }
}
service_status.awk:

Code: Select all

#!/bin/awk -f
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# This script will parse nagios's status.log file usually located in /usr/local/nagios/var/
# or /usr/local/groundwork/nagios/var/ (if using groundwork) and is supposed to look for all services
# that have notifications turned off.  This can be useful to remind a busy sysadmin
# of the services disabled in the middle of the night that he/she may have forgotten.
#
BEGIN { header=0;
        FS="=";
}

/^[[:space:]]*info {[[:space:]]*$/ {
        codeblock="info";
}

/^[[:space:]]*programstatus {[[:space:]]*$/ {
        codeblock="program";
}

/^[[:space:]]*hoststatus {[[:space:]]*$/ {
        codeblock="host";
}

/^[[:space:]]*servicestatus {[[:space:]]*$/ {
        codeblock="service";
        host_name="";
        service_description="";
        notifications_enabled="";
}

/^[[:space:]]*host_name=/ {
        host_name=$2;
}

/^[[:space:]]*service_description=/ {
        service_description=$2;
}

/^[[:space:]]*notifications_enabled=/ {
        notifications_enabled=$2;
}

/^[[:space:]]*}[[:space:]]*$/ {
                if (codeblock=="service" && notifications_enabled=="0") {
                                if (header==0) {
                                        print "\n**************************************\nThe following services have notifications turned off:\n";
                                        header=1;
                }
                                print service_description " on " host_name "\n";
        }
}

Re: disabled notifications

Posted: Wed Jun 05, 2013 8:08 am
by BanditBBS
FYI, I did not write this. I found it in the Nagios Exchange. I did need to to modify a little to work for me, so that is why I posted mine and didn't link you to the exchange.

Jim

Re: disabled notifications

Posted: Wed Jun 05, 2013 9:49 am
by sreinhardt
Thanks bandit, that's pretty cool!

Re: disabled notifications

Posted: Wed Jun 05, 2013 12:08 pm
by BanditBBS
sreinhardt wrote:Thanks bandit, that's pretty cool!
I just put in a feature request to get this or something similar built into XI.

http://tracker.nagios.com/view.php?id=410

I think it'd be much nicer to have it built in, that way the devs can worry about making it always work and it makes sense since it is reporting on functionality of Nagios anyway.