Flagging alerts and notifications as urgent
Chris Smith
csmith at radioframenetworks.com
Mon Aug 22 17:42:35 CEST 2005
I needed a way to send alerts from Nagios (incidentally, I am on 2.0b4) but
have them flagged at Urgent. Granted, the RFC surrounding email doesn't allow
for this, but my staff utilize MS Outlook 2k3 and Treo 650 phones, so, I wanted
to flag those emails differently.
With some hacking and perl, here is what I have come up with. Thought that I
would share it with you.
Here is the script file that we placed in /usr/local/bin:
<----------- cut here --------------->
#!/usr/bin/perl
my $line;
print "From: \"Nagios Alert\" <daemon>\n";
print "To: @ARGV[0]\n";
print "Subject: @ARGV[1]\n";
print "Content-Type: text/plain\n";
print "X-Priority: 1\n";
print "X-MSMail-Priority: High\n";
print "\n";
while (<STDIN>) {
$line = $_;
print "$line";
}
print ".\n";
<----------- cut here --------------->
And, we changed the alerting in the misccommands.cfg and command.cfg files:
(from misccommand.cfg)
# 'notify-by-email' command definition
define command{
command_name notify-by-email
command_line /usr/bin/printf "%b" "Note: DO NOT REPLY TO
THIS EMAIL\n\n$NOTIFICATIONTYPE$\nThe service $SERVICEDESC$ on host $HOSTALIAS$
and at address $HOSTADDRESS$ is in a state of $SERVICESTATE$.\n\nThe output
from the service check:$OUTPUT$\n\nService URL: http://<somehost>/nagios/cgi-
bin/extinfo.cgi?type=1&host=$HOSTNAME$\n\n(Note: This link will take you to the
service problem and not show the sidebar.)\n\nNagios homepage:
http://<somehost>/nagios/" | /usr/local/bin/urgent $CONTACTEMAIL$ "**
$NOTIFICATIONTYPE$ alert - $HOSTNAME$ is $HOSTSTATE$ **" | /usr/sbin/sendmail -t
}
(from command.cfg)
# Service notification command - send email with problem summary
command[notify-by-email]=/usr/bin/printf "Note: DO NOT REPLY TO THIS
EMAIL\n\nThe servicestate \"$SERVICESTATE$\" for $HOSTALIAS$ and $SERVICEDESC$
located at IP $HOSTADDRESS$ is in a $HOSTSTATE$ state.\n\nThe output from the
host check: $OUTPUT$\n\nHost URL:\"http://<somehost>/nagios/cgi-bin/extinfo.cgi?
type=2&host=$HOSTNAME$\"\n(Note: This link will take you to the host in
question and not show the sidebar.)\n\nNagios homepage:
http://<somehost>/nagios/" | /usr/local/bin/urgent $CONTACTEMAIL$ "$HOSTALIAS$
is in a $HOSTSTATE$ state" | /usr/sbin/sendmail -t
Christopher M. Smith
I.T. Manager
RadioFrame Networks
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list