4 use Mail
::Sendmail
0.75; # doesn't work with v. 0.74!
6 $NOTIFICATIONTYPE=$ARGV[0];
11 $SHORTDATETIME=$ARGV[5];
16 $boundary = "====" . time() . "====";
18 $text = "***** Notification Shinken *****\n\n"
19 . "Notification : $NOTIFICATIONTYPE\n\n"
20 . "Host : $HOSTNAME\n\n"
21 . "Address : $HOSTADDRESS\n"
22 . "State : $HOSTSTATE\n\n"
23 . "Date/Time : $SHORTDATETIME\n\n"
24 . "Host output : $HOSTOUTPUT";
26 $texthtml = " <center><table border='11><th><strong>***** Notification Shinken *****</strong></th></table></center>\n";
29 if ($NOTIFICATIONTYPE =~ /RECOVERY/) {
32 if ($NOTIFICATIONTYPE =~ /PROBLEM/) {
36 $HOSTOUTPUT =~ s/=/=/g;
38 $texthtml = $texthtml . "<strong>Notification type : <span style='ccolor:$color> $NOTIFICATIONTYPE </span></strong>\n\n";
42 $texthtml = $texthtml . "<strong><i><span style='ccolor:$color>This device is actually in maintenance.</span></i></strong>\n\n";
45 if ($HOSTSTATE =~ /DOWN/) {
48 if ($HOSTSTATE =~ /UP/) {
51 if ($HOSTSTATE =~ /UNREACHABLE/) {
55 $texthtml = $texthtml . "<strong>Impacted host</strong> : $HOSTNAME\n"
56 . "<strong>Address</strong> : <i>$HOSTADDRESS</i> \n"
57 . "<strong>Host State : <span style='ccolor:$color> $HOSTSTATE </span></strong>\n"
58 . "<strong>Date/Time</strong> : <i>$SHORTDATETIME</i> \n\n"
59 . "<strong>Host Output</strong> : $HOSTOUTPUT \n\n\n\n";
63 from
=> 'Monitoring Agent <monitor-agent@invaliddomain.org>',
65 subject
=> "$HOSTNAME is $HOSTSTATE !",
66 'content-type' => "multipart/alternative; boundary=\"$boundary\"",
67 'Auto-Submitted' => "auto-generated"
70 $plain = encode_qp
$text;
72 #$html = encode_entities($texthtml);
74 $html =~ s/\n\n/\n\n<p>/g;
75 $html =~ s/\n/<br>\n/g;
76 $html = "<p>" . $html . "</p>";
78 $boundary = '--'.$boundary;
80 $mail{body
} = <<END_OF_BODY;
82 Content-Type: text/plain; charset="utf-8"
83 Content-Transfer-Encoding: quoted-printable
88 Content-Type: text/html; charset="utf-8"
89 Content-Transfer-Encoding: quoted-printable
95 sendmail(%mail) || print "Error: $Mail::Sendmail::error\n";