Using a script to send custom email alerts from Live Exceptions

book

Article ID: 50495

calendar_today

Updated On:

Products

EHEALTH CA eHealth

Issue/Introduction

Description:

By default the Notifier "Send Email" rule will populate an email alert message with all details of an alarm. In order to customize the content of these emails, one must write a custom script and use the "Run Command" rule type. This document provides a sample Perl script that can be customized for individual use.

Solution:

In order to send a customized email message, you should create a new Notifier rule with the "Run Command" action instead of the "Send Email" action. You will need to create a custom script in your preferred scripting language that will actually perform the "send email" action. This document uses Perl to provide sample content.

The screenshot below shows a sample Notifier rule to run a script is attached to this document. Please note that the script MUST be saved somewhere within the $NH_HOME directory tree, and the full path and file name must be specified. It could be in a subdirectory, such as D:/ehealth/log, or at the home level, D:/ehealth. The screenshot uses the $NH_HOME level for example purposes only, it is not a requirement. Regardless of operating system, you should use UNIX-style forward slashes when entering the directory path.

<Please see attached file for image>

Figure 1

When creating a script to run the mail command, you can use any scripting language that you are comfortable with and that can be run on the eHealth server. The attached sample uses Perl. As with other facets of eHealth, CA Technical Support supports the use of scripts but not the writing and debugging of scripts. We advise you consult your company's programming team or contact Professional Services if you require coding assistance.

For convenience the contents of the sample script are listed below. Note that when using Perl, you can pass line breaks through in the body of the message with a '\n' argument. In order for Perl to read special characters properly they must be preceded by a backlash, thus the argument is entered as \\n.

   ############################################   
   # Live Exceptions passes the variables in the following order to the script:   
   # $1 = severity   
   # $2 = start time   
   # $3 = start time (Coordinated UTC integer)   
   # $4 = element name   
   # $5 = rule message   
   # $6 = tech type   
   # $7 = variable   
   # $8 = problem start time (text)   
   # $9 = problem start time (UTC integer)   
   # $10 = problem duration (integer seconds)   
   # $11 = rule condition type   
   # $12 = profile name   
   # $13 = group name   
   # $14 = Reserved   
   # $15 = event carrier   
   # $16 = IP address (decimal notation)   
   # $17 = reason   
   # $18 = server port   
   # $19 = server IP address   
   # $20 = eHealth server name   
   # $21 = element ID   
   # $22 = element alias name   
   # $23 = component   
   # $24 = description   
   # $25 = alarm ID   
   # $26 = Ack   
   # $27 = Ack user   
   # $28 = Ack time   
   # $29 = Ack time (UTC integer)   
   # $30 = Annotation1   
   # $31 = Annotation2   
   # $32 = Annotation3   
   # $33 = Annotation4   
   ############################################  
   # arguments   
   $severity=$ARGV[0];   
   $start=$ARGV[1];   
   $element=$ARGV[3];   
   $message=$ARGV[4];   
   $group=$ARGV[12];   
   $notes="Please Page the NOC";   
   $description=$ARGV[23];   
   $email="thomi12\@ca.com";  
   # subroutine "mailit"   
   # send alarm to email address   
   #   
   # format of the nhMail command used here:   
   # nhMail -e [subject] [body] [recipient]   
   # subject and body must each be within double quotes  
   sub mailit {   
   system("E:/eHealth/bin/nhMail -e \"$severity \- $element \- $message\" \"$start\\n\\n$notes\" $email");   
   }  
   mailit  

When an alarm is raised that triggers this Notifier rule, the email message will look something like this:

   From: [email protected] [mailto:[email protected]]   
   Sent: Wednesday, February 16, 2011 6:52 AM   
   To: Thompson, Michael   
   Subject: warning - testServer-SH - Test Alarm  
   2/16/2011 06:51:30 AM  
   Please Page the NOC  

You can modify the $notes variable to send any message you desire. Likewise, if you want to send the email message to multiple recipients simply modify the value of the $email variable. On UNIX systems, separate e-mail addresses with a semicolon. On Windows systems, separate e-mail addresses with a plus sign.

Environment

Release: LHBASC99000-6.2-eHealth-Live Health Upgrade Elements
Component:

Attachments

1558698169375000050495_sktwi1f5rjvs16o5z.gif get_app
1558535243534TEC544385.zip get_app