From 2f5e66166ff595dff2486ff1a17fad325587b551 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B3mas=20Edwardsson?= Date: Mon, 10 May 2010 12:31:43 +0000 Subject: [PATCH] Added links for acknowledgement and downtime to nagios mailer --- .../trunk/perty-nagios-mailer.pl | 62 ++++++++++++++++--- 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/perty-nagios-mailer.pl/trunk/perty-nagios-mailer.pl b/perty-nagios-mailer.pl/trunk/perty-nagios-mailer.pl index 4523f9b..2028f87 100644 --- a/perty-nagios-mailer.pl/trunk/perty-nagios-mailer.pl +++ b/perty-nagios-mailer.pl/trunk/perty-nagios-mailer.pl @@ -28,7 +28,7 @@ my $pnp4nagios_phpdir = '/usr/share/nagios/html/pnp4nagios'; my $nagios_cgiurl = "http://nagios/nagios/cgi-bin"; my $pnp4nagios_url = "http://nagios/nagios/pnp4nagios/"; my $from_address = 'nagios@opensource.is'; -my $logo = '/usr/share/nagios/images/sblogo.png'; +my $logo = '/usr/share/nagios/html/images/sblogo.png'; if (@ARGV != 8) { usage(); @@ -36,6 +36,11 @@ if (@ARGV != 8) { my ($recipient, $date, $type, $host, $ip, $service, $state, $message) = @ARGV; +my %nagioscmd = ( + service_downtime => 56, + service_ack => 34, +); + my $rrd = ''; if (-f "$pnp4nagios_perfdata/$host/$service.rrd") { my $t = time(); @@ -68,44 +73,85 @@ EO ); my $state_color = '#33FF00'; + if ($state eq 'WARNING') { $state_color = '#FFFF00'; } elsif ($state eq 'CRITICAL') { $state_color = '#F83838'; } + +my $ack = ''; +if ($state ne 'OK') { + my $ackurl = sprintf("%s/cmd.cgi?host=%s&service=%s", + $nagios_cgiurl, + $host, + $service); + $ack = qq{ + + Service Actions + Acknowledge Schedule Downtime + +}; +} + my $html_content = MIME::Entity->build( Type => 'text/html', Charset => 'UTF-8', Encoding => 'quoted-printable', Data => qq{ + + + - + - + - + - + - + - + +$ack - +
HostHost $host ($ip)
ServiceService $service
StateState $state
DateDate $date
TypeType $type
DescriptionDescription
$message