disabled notifications
Posted: Tue Jun 04, 2013 10:00 am
Is there anyway to identify service/host checks where the notifications that have been disabled? i.e. a report of some sort.
Support for Nagios products and services
https://support.nagios.com/forum/
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
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";
}
}
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";
}
}
I just put in a feature request to get this or something similar built into XI.sreinhardt wrote:Thanks bandit, that's pretty cool!