disabled notifications

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
paul.jobb
Posts: 167
Joined: Tue Aug 02, 2011 4:37 pm

disabled notifications

Post 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.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: disabled notifications

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: disabled notifications

Post 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.
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: disabled notifications

Post 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";
        }
}
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: disabled notifications

Post 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
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: disabled notifications

Post by sreinhardt »

Thanks bandit, that's pretty cool!
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: disabled notifications

Post 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.
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
Locked