Page 1 of 1

conditional email notification and template using

Posted: Tue Dec 23, 2014 12:03 pm
by zaji_nms
Dear Expert

Is there any way to use customized message depend on the link status, if CRITICAL (DOWN) will send
"Dear Customer : We observed your link is down, please check power status and revert back ......"

If link comes UP (RECOVER) will shoot different message.
"Dear Customer : We observed link is up now and will update you with RFO"

I found there is Template, but how to use? Please provide URL as a full documentation.

This Email Notification Template can be use with condition?
If link DOWN, send message with using Template1 , if link UP, send message using Template2 ?

Regards

Re: conditional email notification and template using

Posted: Tue Dec 23, 2014 12:14 pm
by tgriep
Here is the link on how to create Custom Notifications.

http://assets.nagios.com/downloads/nagi ... iables.pdf

Let us know if that is what you are looking for.

Re: conditional email notification and template using

Posted: Tue Dec 23, 2014 2:15 pm
by zaji_nms
Dear tgriep

No

Please note, using default Template_1, Email Notification working fine but need control via Template or via some script (the below is some sort of example, its not real).

<PHP/>
if %hoststate%="DOWN" then
echo "Dear Customer : We observed link DOWN please check power status...."
elseif %hoststate%="RECOVER"
echo "Dear Customer : Now link UP and will provide you RFO"
endif
<PHP>

Notification Settings Management
Please let me know how/where to use Notification Template_2 (if we create it).

Re: conditional email notification and template using

Posted: Tue Dec 23, 2014 2:36 pm
by lmiltchev
You can type any "custom" message in the "Host Alert Message" and "Service Alert Message" fields. You can use macros, and html/css tags to show some color. Here's an example of a "custom" host/service alert messages with some color :)

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%
Once you set the template the way you want it, you can apply it to some users, or make it default for all users (if you are using Nagios XI Enterprise Edition). You can even lock the notification messages and settings for the selected non-admin users.

Hope this helps.

Re: conditional email notification and template using

Posted: Wed Dec 24, 2014 7:38 am
by zaji_nms
Dear lmiltchev

Thanks for the reply, but that is for cosmetic change (not my first priority/question), me wants to shoot the custom message upon the state of the link.
As I typed before (color is not my priority, me looking for the to use condition (if then else))

Dear Customer
if link down
We observed Link down, please check power status from your end and meanwhile we checking from our end.
endif
if link recover
We observed Link is up now , will provide RFO (Reason for Outage).
endif
if service having word bandwidth and state=critical
We observed there High bandwidth Utilization will cause delay/packet loss. Please check from your end or let us know for any assistance.
endif


I have changed my message (common message for all the alert) which is not good for our valued customer....If possible guide me....if not may be you can think for feature add in future.

New common message on all the alerts (which is not good)
Dear Customer
This is Auto generated message by NMS System as there is change in link state.
Display Name:
State:
Notification Type:
Info:
Date/Time (DD/MM/YYYY HH:MM:SS)
Regards

Re: conditional email notification and template using

Posted: Fri Dec 26, 2014 11:02 am
by scottwilkerson
Unfortunately, this is not possible with the XI notification handler, however, you can switch your contacts to use custom notification handlers if you like creating a script that processes the notifications however you like.

Re: conditional email notification and template using

Posted: Sat Dec 27, 2014 1:17 am
by zaji_nms
Dear scottwilkerson

Thanks for clarification.

If you have some guideline , please post here how can be done (5-10 lines code), otherwise you can close the case. I am strongly thinking to have some PHP training which will give more value of NagiosXI to us.

Regards

Re: conditional email notification and template using

Posted: Mon Dec 29, 2014 9:41 am
by tmcdonald
Take a look at pages 2 and 3 of this doc:

http://assets.nagios.com/downloads/nagi ... ios-XI.pdf

It explains the notification commands available by default. In order to add your own, you will need to script it out (which will certainly take more than 5-10 lines of code) and place the script in the /usr/local/nagios/libexec/ directory. From there you can set that up as a new command in XI and use that command as your notification handler for your contacts.

Re: conditional email notification and template using

Posted: Mon Dec 29, 2014 2:06 pm
by zaji_nms
Dear tmcdonald

Okay, you can close the case, but as Nagios grow, you can think to add such feature.

Regards