[Nagios-devel] Patch: send html notification with dynamic hyperlinks to Nagios pages

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] Patch: send html notification with dynamic hyperlinks to Nagios pages

Post by Guest »

This is a multi-part message in MIME format.

------=_NextPart_000_0005_01C3A3F3.8BE077B0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Overview
--------

Add to Nagios notify commands the capability to send HTML email messages
with url encoded hostnames and servicedescs.

This patch makes possible to send HTML notifications with clickable =
dynamic
links to quickly access the pages with details about the problem Nagios =
is
reporting.=20
Very useful for large installations or smart help desks :)

You can find a screenshot as attachment where it is shown the final=20
result from user point of view. The four links in the screenshot will=20
point to the appropriate pages.


Patch it
--------

To make all of this working you have to:

1) Apply the patch
=20
cd /base
patch utils.c /htmlmail.diff
make;strip nagios;cp nagios /bin
=20
Now set /bin/nagios permissions as those of =
the
other files in that dir and you have finished.

2) Replace the commands in the attached misccommands.cfg with the same
commands in your misccommands.cfg and replace the http://nagiosbox =
string
with the one identifying your Nagios server. I've used sendmail to send
emails but you can replace the "/usr/sbin/sendmail -t" command with your
favorite mailer.

Note for NAGAT users: the edit textarea to change misccommands.cfg =
entries
is stripping "\" characters. Beware of this and edit this file by hand
rather than with Nagat or you will not receive any email. I'm not aware =
of
problems with other web interfaces because I've not tested them. I =
suggest
you to edit this file by hand.

You'll note that there are two new fields that Nagios does not provide:
$ENCODEDHOSTNAME$ and $ENCODEDSERVICEDESC$.
The patch code adds the two new fields to those available in Nagios.

3) Restart Nagios by issuing a STOP and a START command (not RELOAD).
Wait for the next emails and enjoy :)

Nagios it (for Ethan)
---------------------

I think this would be a good cosmetic feature for notifications in =
Nagios
v2.0.
I'm sorry but I had no time to implement it against v2.0 CVS, I hope =
this is
not a problem to merge this code into 2.0.

=20
FINAL NOTE: The only annoying thing to care about is that images are not
displayed properly if you have implemented secure access to Nagios site =
and
you are not logged in before reading the email. If you don't care about =
this
I suggest you to strip images from the email code.

------------

Stefano Coletta
http://www.mindcreations.com=20

------=_NextPart_000_0005_01C3A3F3.8BE077B0
Content-Type: application/octet-stream;
name="htmlmail.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="htmlmail.diff"

212a213,267=0A=
> /* Function imported from cgi/cgiutils.c */=0A=
> /* Added by Stefano Coletta (aka Creator) http://www.mindcreations.com =
on 05/11/2003 */=0A=
> =0A=
> /* encodes a string in proper URL format */=0A=
> =0A=
> char encoded_url_string[MAX_INPUT_BUFFER];=0A=
> =0A=
> char * url_encode(char *input){=0A=
> int len,output_len;=0A=
> int x,y;=0A=
> char temp_expansion[4];=0A=
> =0A=
> len=3D(int)strlen(input);=0A=
> output_len=3D(int)sizeof(encoded_url_string);=0A=
> =0A=
> encoded_url_string[0]=3D'\x0';=0A=
> =0A=
> for(x=3D0,y=3D0;x =0A=
> /* end of string */=0A=
> if((char)input[x]=3D=3D(char)'\x0'){=0A=
> encoded_url_string[y]=3D'\x0';=0A=
> break;=0A=
> }=0A=
> =0A=
> /* alpha-numeric characters don't get encoded */=0A=
> else if(((char)input[x]>=3D'0' && =
(char)input[x]=3D'A' && =
(char)input[x] [x]>=3D(char)'a' && (char)input[x] encoded_url_string[y]=3Dinput[x];=0A=
>

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked