Page 1 of 1
Send-HTML-Alert-Email
Posted: Tue Sep 23, 2014 5:25 am
by cyient
Hi,
We are trying yo implement HTML formatted emails given in the below link. But we are not receiving alerts as intended.
http://exchange.nagios.org/directory/Pl ... il/details
Defined a command named
notify-host-by-email_1 for host with command line as
Code: Select all
$USER1$/nagios_host_mail "$NOTIFICATIONTYPE$" "$HOSTNAME$" "$HOSTALIAS$" "$HOSTSTATE$" "$HOSTADDRESS$" "$HOSTOUTPUT$" "$LONGDATETIME$" "$SERVICEDESC$" "$SERVICESTATE$" "$CONTACTEMAIL$" "$TOTALHOSTSUP$" "$TOTALHOSTSDOWN$"
Defined a command named
notify-service-by-email_1 for service with command line as
Code: Select all
$USER1$/nagios_service_mail "$NOTIFICATIONTYPE$" "$HOSTNAME$" "$HOSTALIAS$" "$HOSTSTATE$" "$HOSTADDRESS$" "$SERVICEOUTPUT$" "$LONGDATETIME$" "$SERVICEDESC$" "$SERVICESTATE$" "$CONTACTEMAIL$" "$SERVICEDURATIONSEC$" "$SERVICEDOWNTIME$" "$TOTALSERVICESWARNING$" "$TOTALSERVICESCRITICAL$" "$TOTALSERVICESUNKNOWN$"
Copied the files
nagios_service_mail.php and
nagios_host_mail.php to /usr/local/nagios/libexec/ folder after renaming to
nagios_service_mail and
nagios_host_mail respectively.
Can anyone help me with this ?
Re: Send-HTML-Alert-Email
Posted: Tue Sep 23, 2014 9:38 am
by abrist
Do you have XI with enterprise? If so, it already provides HTML emails.
Or is this a Nagios Core question?
Re: Send-HTML-Alert-Email
Posted: Tue Sep 23, 2014 12:28 pm
by snapon_admin
Is there any documentation on how to configure this if you have enterprise features? I am also interested in this, and if it's something that's included with enterprise I'd love to try it out.
Re: Send-HTML-Alert-Email
Posted: Tue Sep 23, 2014 12:43 pm
by lmiltchev
I believe Andy mentioned Enterprise, because in Enterprise, there is a "Notification Setting Management" page, where you can set up contact templates, and apply them to some/all users.
I don't believe we have a document about how to set up HTML emails in XI, but basically, you can use html tags or css in both Nagios XI Standard and Enterprise Edition.
Each user can modify his/her notification options, so, for example, one can have in the "Host Alert Message" and "Service Alert Message" text boxes something like this:
Code: Select all
<style type='text/css'>.UP {color:green;}.DOWN {color:red;}.UNREACHABLE {color:orange}</style>
<h2 class='%hoststate%'>***** Nagios XI Alert *****</h2>
%alertsummary%
Notification Type: %type%
Host: %host%
State: <strong class='%hoststate%'>%hoststate%</strong>
Address: %hostaddress%
Hostgroup: %hostgroupnames%
Info: %hostoutput%
Date/Time: %datetime%
Host Notes: <font color="green">%hostnotes%</font>
Host Duration: %hostduration%
Respond: <href a="%responseurl%">%responseurl%</a>
Nagios URL: %xiserverurl%
Code: Select all
<style type='text/css'>.OK {color:green;}.WARNING {color:yellow;}.UNKNOWN {color:orange}.CRITICAL {color:red}</style>
<h3 class='%servicestate%'>***** Nagios XI Alert *****</h3>
%alertsummary%
Notification Type: %type%
Service Name: %service%
Service Group: %servicegroupnames%
State: <strong class='%servicestate%'>%servicestate%</strong>
Host Name: %host%
Hostalias: %hostalias%
Address: %hostaddress%
Hostgroup: %hostgroupnames%
Info:
%serviceoutput%
%longserviceoutput%
Date/Time: %datetime%
Service Notes: <font color="green">%servicenotes%</font>
Respond: %responseurl%
Nagios URL: %xiserverurl%
Hope this helps.
Re: Send-HTML-Alert-Email
Posted: Tue Sep 23, 2014 12:54 pm
by abrist
Use the "Notification Management" templates. Embed your html right there. For example:
Code: Select all
<h3>***** Nagios XI Alert *****</h3>
<img src="http://assets.nagios.com/images/header/Nagios.png"/>
%alertsummary%
[snip]
Re: Send-HTML-Alert-Email
Posted: Thu Sep 25, 2014 1:29 am
by cyient
Thank you for the suggestion, i have made modifications for the Notification template.
I have one more query is it possible to embed the graph related to the particular host being down or the service critical details in the notification

Re: Send-HTML-Alert-Email
Posted: Thu Sep 25, 2014 2:11 am
by WillemDH
Cyient,
That would be a nice feature!
Grtz
Re: Send-HTML-Alert-Email
Posted: Thu Sep 25, 2014 10:13 am
by lmiltchev
cyient,
You are welcome to post a feature request on our
public tracker or I can post an internal one (if you want me to).
Can we lock the topic as "resolved"? Thanks!
Re: Send-HTML-Alert-Email
Posted: Fri Sep 26, 2014 12:07 am
by cyient
lmiltchev wrote:cyient,
You are welcome to post a feature request on our
public tracker or I can post an internal one (if you want me to).
Can we lock the topic as "resolved"? Thanks!
Please post it in the internal one and you can lock the topic as resolved.
Re: Send-HTML-Alert-Email
Posted: Fri Sep 26, 2014 9:36 am
by abrist
Alright.