RFC: Proposal for a new patch before releasing of v2.0 (to be included)
Stefano Coletta
creator at mindcreations.com
Wed Nov 5 10:23:09 CET 2003
Hello,
I've patched Nagios to add support for HTML email with urlencoded
parameters.
You can find a screenshot as attachment where it is shown the final
result from user point of view. The four links in the screenshot will
point to the appropriate pages.
Here are the new commands to send emails:
define command {
command_name notify-by-email
command_line /usr/bin/printf "%b" "To:
$CONTACTEMAIL$\r\nMime-Version: 1.0\r\nContent-Type:
text/html\r\nContent-Base: http://nagiosbox\r\nSubject: $SERVICESTATE$
alert for $HOSTALIAS$/$SERVICEDESC$\x21\r\n\r\n***** Nagios 1.1
*****<br><br>Notification Type: $NOTIFICATIONTYPE$<br>Host:
$HOSTNAME$<br>Service: $SERVICEDESC$<br>State:
$SERVICESTATE$<br>Address: $HOSTADDRESS$<br>Info:
$OUTPUT$<br><br>Date/Time: $DATETIME$<br><br><A
href=\"/cgi-bin/avail.cgi?host=$ENCODEDHOSTNAME$&show_log_entries\"><img
src=\"/images/trends.gif\" border=\"0\" alt=\"Command\"> Show
availability report</A><br><A
href=\"/cgi-bin/extinfo.cgi?type=2&host=$ENCODEDHOSTNAME$&service=$ENCODEDSERVICEDESC$\"><img
src=\"/images/status2.gif\" border=\"0\" alt=\"Command\"> Show service
details</A><br><A
href=\"/cgi-bin/statusmap.cgi?layout=1&host=$ENCODEDHOSTNAME$\"><img
src=\"/images/status3.gif\" border=\"0\" alt=\"Command\"> Locate on
Map</A><br><A href=\"/cgi-bin/status.cgi?host=$ENCODEDHOSTNAME$\"><img
src=\"/images/status2.gif\" border=\"0\" alt=\"Command\"> Show
services</A><br>" | /usr/sbin/sendmail -t
}
define command {
command_name host-notify-by-email
command_line /usr/bin/printf "%b" "To:
$CONTACTEMAIL$\r\nMime-Version: 1.0\r\nContent-Type:
text/html\r\nContent-Base: http://nagiosbox\r\nSubject: Host $HOSTSTATE$
alert for $HOSTNAME$\x21\r\n\r\n***** Nagios 1.1
*****<br><br>Notification Type: $NOTIFICATIONTYPE$<br>Host:
$HOSTNAME$<br>State: $HOSTSTATE$<br>Address: $HOSTADDRESS$<br>Info:
$OUTPUT$<br><br>Date/Time: $DATETIME$<br><br><A
href=\"/cgi-bin/avail.cgi?host=$ENCODEDHOSTNAME$&show_log_entries\"><img
src=\"/images/trends.gif\" border=\"0\" alt=\"Command\"> Show
availability report</A><br><A
href=\"/cgi-bin/extinfo.cgi?type=1&host=$ENCODEDHOSTNAME$\"><img
src=\"/images/status2.gif\" border=\"0\" alt=\"Command\"> Show host
details</A><br><A
href=\"/cgi-bin/statusmap.cgi?layout=1&host=$ENCODEDHOSTNAME$\"><img
src=\"/images/status3.gif\" border=\"0\" alt=\"Command\"> Locate on
Map</A><br><A href=\"/cgi-bin/status.cgi?host=$ENCODEDHOSTNAME$\"><img
src=\"/images/status2.gif\" border=\"0\" alt=\"Command\"> Show
services</A><br>" | /usr/sbin/sendmail -t
}
As you can note there are two new fields that Nagios does not provide:
$ENCODEDHOSTNAME$ and $ENCODEDSERVICEDESC$.
To make it work for your installation you have to replace the
http://nagiosbox string with the one identifying your Nagios server.
I've also used sendmail to send emails but you can replace the
"/usr/sbin/sendmail -t" command with your favorite mailer.
The patch adds the two new fields to those available in Nagios.
I'll send the diff code shortly.
--
Stefano Coletta
http://www.mindcreations.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: htmlmail.gif
Type: image/gif
Size: 48545 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/users/attachments/20031105/68093446/attachment.gif>
More information about the Users
mailing list