On Mon, Sep 15, 2008 at 10:32 AM, Jorge Peña <[EMAIL PROTECTED]> wrote:
> Hello list,
>
> I have a running instalation of Nagios capable to acknowledge via web
> interface and SMS (I followed some tutorial for that).
>
> I guessed Nagios had implemented by default the acknowledgementent via
> e-mail by default just replying to the e-mail but I discovered that it
> doesn't work.
>
> Somebody did? how?
>
> Regards,
> Jorge
>
>
1) install postfix
2) install procmail
3) use the following procmailrc for the nagios user:
LOGFILE=$HOME/.procmailrc.log
VERBOSE=yes
PATH=/usr/bin
:0
* ^Subject:[]*\/[^ ].*
| /usr/lib/nagios/eventhandlers/processmail "${MATCH}"
4) /usr/lib/nagios/eventhandlers/processmail is at the end of this email
5) the program assumes notifications are formatted like mine. I put them at
the end of this email too.
6) when you receive an alert on your blackberry while at the bar, simply
reply to the email and prepend the subject of the alert with:
"something ack"
I'm probably missing some things so if it doesn't work right away, post back
and I'll help as much as I can. This comes with no warranty. Its poorly
written perl. It probably has a huge security hole. There's probably a
better way to do this. It very well may turn your servers into an Atom bomb
and blow up the moon. Just warning you... :)
Thanks,
Terry
define command{
command_namenotify-by-email
command_line/usr/bin/printf "%b" "Notification Type:
$NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress:
$HOSTADDRESS$\nState: $SERVICESTATE$\nNotification Number:
$SERVICENOTIFICATIONNUMBER$\n\nDate/Time: $LONGDATETIME$\n\nAdditional
Info:\n\n$SERVICEOUTPUT$" | /usr/lib/nagios/eventhandlers/notification
$SERVICENOTIFICATIONNUMBER$ localhost [EMAIL PROTECTED] $CONTACTEMAIL$ "**
$NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **"
service
}
define command{
command_namenotify-by-epager
command_line/usr/bin/printf "%b" "Service: $SERVICEDESC$\nHost:
$HOSTNAME$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\nNotification
Number: $SERVICENOTIFICATIONNUMBER$\nInfo: $SERVICEOUTPUT$\nDate:
$LONGDATETIME$" | /usr/bin/sendEmail -s localhost -f [EMAIL PROTECTED] -t
$CONTACTEMAIL$ -u "$NOTIFICATIONTYPE$: $HOSTALIAS$/$SERVICEDESC$ is
$SERVICESTATE$"
}
define command{
command_namehost-notify-by-email
command_line/usr/bin/printf "%b" "Notification Type:
$NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nNotification
Number: $HOSTNOTIFICATIONNUMBER$\nAddress: $HOSTADDRESS$\nInfo:
$HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" |
/usr/lib/nagios/eventhandlers/notification $HOSTNOTIFICATIONNUMBER$
localhost [EMAIL PROTECTED] $CONTACTEMAIL$ "Host $HOSTSTATE$ alert for
$HOSTNAME$!" host
}
define command{
command_namehost-notify-by-epager
command_line/usr/bin/printf "%b" "Host '$HOSTALIAS$' is
$HOSTSTATE$\nInfo: $HOSTOUTPUT$\nTime: $LONGDATETIME$" | /usr/bin/sendEmail
-s localhost -f [EMAIL PROTECTED] -t $CONTACTEMAIL$ -u "$NOTIFICATIONTYPE$
alert - Host $HOSTNAME$ is $HOSTSTATE$"
}
#!/usr/bin/perl
$correctpassword = 'something';
$subject = "$ARGV[0]";
$now = `/bin/date +%s`;
chomp $now;
$commandfile = '/var/log/nagios/rw/nagios.cmd';
if ($subject =~ /Host/ ){
($password, $what, $junk, $junk, $junk, $junk, $junk, $host) =
split(/ /, $subject);
($host) = ($host) =~ /(.*)\!/;
} else {
($foo, $bar) = split(/\//, $subject);
($password, $what, $junk, $junk, $junk, $junk, $junk, $host) =
split(/ /, $foo);
($service) = $bar =~ /^(.*) is.*$/;
}
$password =~ s/^\s+//;
$password =~ s/\s+$//;
print "$password\t$what\t$host\t$service\n";
unless ($password =~ /$correctpassword/i) {
print "exiting...wrong password\n";
exit 1;
}
# ack
if ($subject =~ /Host/ ) {
$ack =
"ACKNOWLEDGE_HOST_PROBLEM;$host;1;1;1;email;email;acknowledged through
email";
} else {
$ack =
"ACKNOWLEDGE_SVC_PROBLEM;$host;$service;1;1;1;email;acknowledged through
email";
}
if ($what =~ /ack/i) {
sub_print("$ack");
} else {
print "no valid commands...exiting\n";
exit 1;
}
sub sub_print {
$narf=shift;
open(F, ">$commandfile") or die "cant";
print F "[$now] $narf\n";
close F;
}
-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/___
Nagios-users mailing list
Nagios-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please incl