Send-HTML-Alert-Email

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
cyient
Posts: 116
Joined: Thu May 08, 2014 4:45 am

Send-HTML-Alert-Email

Post 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 ?
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Send-HTML-Alert-Email

Post by abrist »

Do you have XI with enterprise? If so, it already provides HTML emails.
Or is this a Nagios Core question?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
User avatar
snapon_admin
Posts: 952
Joined: Mon Jun 10, 2013 10:39 am
Location: Kenosha, WI
Contact:

Re: Send-HTML-Alert-Email

Post 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.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Send-HTML-Alert-Email

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Send-HTML-Alert-Email

Post 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]
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
cyient
Posts: 116
Joined: Thu May 08, 2014 4:45 am

Re: Send-HTML-Alert-Email

Post 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 :?:
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Send-HTML-Alert-Email

Post by WillemDH »

Cyient,

That would be a nice feature!

Grtz
Nagios XI 5.8.1
https://outsideit.net
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Send-HTML-Alert-Email

Post 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!
Be sure to check out our Knowledgebase for helpful articles and solutions!
cyient
Posts: 116
Joined: Thu May 08, 2014 4:45 am

Re: Send-HTML-Alert-Email

Post 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.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Send-HTML-Alert-Email

Post by abrist »

Alright.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked