From 6c89839b7fc344608e61c8916ac9d9925fa98d14 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 5 Oct 2012 06:46:27 +0200 Subject: Monitoring/\* --> nagios/ --- Monitoring/nagios/plugins/sendmailhost.pl | 96 +++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100755 Monitoring/nagios/plugins/sendmailhost.pl (limited to 'Monitoring/nagios/plugins/sendmailhost.pl') diff --git a/Monitoring/nagios/plugins/sendmailhost.pl b/Monitoring/nagios/plugins/sendmailhost.pl new file mode 100755 index 00000000..51e85670 --- /dev/null +++ b/Monitoring/nagios/plugins/sendmailhost.pl @@ -0,0 +1,96 @@ +#!/usr/bin/perl +use MIME::QuotedPrint; +use HTML::Entities; +use Mail::Sendmail 0.75; # doesn't work with v. 0.74! + +$NOTIFICATIONTYPE=$ARGV[0]; +$HOSTNAME=$ARGV[1]; +$HOSTSTATE=$ARGV[2]; +$HOSTADDRESS=$ARGV[3]; +$HOSTOUTPUT=$ARGV[4]; +$SHORTDATETIME=$ARGV[5]; +$TO=$ARGV[6]; +#$HOSTNAME=$ARGV[7]; +#$DOWNTIME=$ARGV[8]; + +$boundary = "====" . time() . "===="; + +$text = "***** Notification Shinken *****\n\n" + . "Notification : $NOTIFICATIONTYPE\n\n" + . "Host : $HOSTNAME\n\n" + . "Address : $HOSTADDRESS\n" + . "State : $HOSTSTATE\n\n" + . "Date/Time : $SHORTDATETIME\n\n" + . "Host output : $HOSTOUTPUT"; + +$texthtml = "
$NOTIFICATIONTYPE \n\n"; + +if ($DOWNTIME != 0) { + $color="#3333FF"; + $texthtml = $texthtml . " $HOSTSTATE \n" + . "Date/Time : $SHORTDATETIME \n\n" + . "Host Output : $HOSTOUTPUT \n\n\n\n"; + + +%mail = ( + from => 'Monitoring Agent ', + to => $TO, + subject => "$HOSTNAME is $HOSTSTATE !", + '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