RFC: Proposal for a new patch before releasing of v2.0 (to be included)

Ethan Galstad nagios at nagios.org
Thu Nov 6 07:14:27 CET 2003


It would seem wiser to simply pass the host name and service 
description macros as arguments to a notification script.  The script 
could then url encode them before sending them out in an email 
message.

On 5 Nov 2003 at 10:23, Stefano Coletta wrote:

> 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\"><i
> mg src=\"/images/trends.gif\" border=\"0\" alt=\"Command\"> Show
> availability report</A><br><A
> href=\"/cgi-bin/extinfo.cgi?type=2&host=$ENCODEDHOSTNAME$&service=$ENC
> ODEDSERVICEDESC$\"><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\"><i
> mg 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
> 
> 



Ethan Galstad,
Nagios Developer
---
Email: nagios at nagios.org
Website: http://www.nagios.org



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?   SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/




More information about the Developers mailing list