Page 1 of 1

Notification with color

Posted: Mon Feb 02, 2015 3:51 pm
by jkinning
With Nagios Core when Nagios sent a notification that was critical it was done so in red. Recovery was green. Is there a simple way to color code or add color to notifications instead of them just being white with black text?

Re: Notification with color

Posted: Mon Feb 02, 2015 4:50 pm
by lmiltchev
You could use html tags/css in the notification messages. An example:

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 Displayname: %servicedisplayname%
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%