From 9456cfffea015812acf5dcdd2d074e98ca54e720 Mon Sep 17 00:00:00 2001 From: euer Date: Sun, 23 Dec 2012 00:21:25 +0100 Subject: //Monitoring -> //god/Monitoring --- god/Monitoring/nagios/plugins/sendmailservices.pl | 105 ++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100755 god/Monitoring/nagios/plugins/sendmailservices.pl (limited to 'god/Monitoring/nagios/plugins/sendmailservices.pl') diff --git a/god/Monitoring/nagios/plugins/sendmailservices.pl b/god/Monitoring/nagios/plugins/sendmailservices.pl new file mode 100755 index 00000000..ab5464cf --- /dev/null +++ b/god/Monitoring/nagios/plugins/sendmailservices.pl @@ -0,0 +1,105 @@ +#!/usr/bin/perl +use MIME::QuotedPrint; +use HTML::Entities; +use Mail::Sendmail 0.75; # doesn't work with v. 0.74! + +$NOTIFICATIONTYPE=$ARGV[0]; +$SERVICEDESC=$ARGV[1]; +$HOSTNAME=$ARGV[2]; +$HOSTADDRESS=$ARGV[3]; +$SERVICESTATE=$ARGV[4]; +$SHORTDATETIME=$ARGV[5]; +$SERVICEOUTPUT=$ARGV[6]; +$TO=$ARGV[7]; +#$HOSTNAME=$ARGV[8]; + +$boundary = "====" . time() . "===="; + +$text = "***** Notification Shinken *****\n\n" + . "Notification : $NOTIFICATIONTYPE\n\n" + . "Impacted service : $SERVICEDESC\n" + . "State : $SERVICESTATE\n\n" + . "Related host : $HOSTNAME\n" + . "Address : $HOSTADDRESS\n" + . "Date/Time : $SHORTDATETIME\n\n" + . "Service output : $SERVICEOUTPUT"; + +$texthtml = "
$NOTIFICATIONTYPE\n\n" + . "Impacted service : $SERVICEDESC\n" + . "State : ', + to => $TO, + subject => "$SERVICEDESC $SERVICESTATE on $HOSTNAME", + 'content-type' => "multipart/alternative; boundary=\"$boundary\"", + 'Auto-Submitted' => "auto-generated" + ); + +$plain = encode_qp $text; + +#$html = encode_entities($texthtml); +$html = $texthtml; +$html =~ s/\n\n/\n\n

/g; +$html =~ s/\n/
\n/g; +$html = "

" . $html . "

"; + +$boundary = '--'.$boundary; + + +$mail{body} = <$html +$boundary-- +END_OF_BODY + +sendmail(%mail) || print "Error: $Mail::Sendmail::error\n"; + -- cgit v1.2.3