Network Management / (OpenView-NNM) Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Action script send email

stemon
Occasional Contributor

Action script send email

Hi,

 

could you provide me an example of script that sends automatically an email when a incident occured?

What is the format of the parameter that I have to pass to the script in order to see in the email this information: nodename, intefacename, type of incident.

 

Thanks!

 

Stefano

5 REPLIES
stemon
Occasional Contributor

Re: Action script send email

sorry, an additional question...I want to define a custom correlation rule, where I can find the list of attribute that I can use in the filter editor? (i.e. ${devVendorInterface}) ?

 

Thanks

rodarcqu
Occasional Contributor

Action script send email

stemon
Occasional Contributor

Re: Action script send email

Hi,

 

I use a Linux server. Can I insert in "command" text editor, in the Action tab, this script: "echo "Test message" | mail -s "Test topic" youremail@yourdomain.com" in order to send an email?

 

 

Thanks

Stefano

stemon
Occasional Contributor

Re: Action script send email

I tried to insert a simple script echo ciao >> file.txt in the command text editor but it doesn't work.

How can I run a script? What kind of information I have to insert in command text editor?

 

Highlighted
rodarcqu
Occasional Contributor

Action script send email

Hi Stephano,

 

In order to configure an incident to receivie an email notification: 

  • Be sure that Network Node Manager box is configured for sending emails.
  • Any application for sending and receiving email can be used as long as it has a CLI utility

Note: Most UNIX servers have mailx application installed by default, which is used to send quick email messages (i.e., without opening up a full-featured mail user agent).

1. Go to Configuration -> Incident configuration -> Management Events Configuration tab.

2. As an example, open Node Down from the list, then the Actions Configuration tab.

3. In Command Type use: ScriptOrExecutable

4. Add a new command*, using the "Registered" lifecycle state. Here are some examples of commands that could be used:

/usr/bin/mailx -s "$snn - Node Down" user@localhost </dev/null

or

echo "Subject:Node $sourceObjectName Down" | /usr/sbin/sendmail <email ID>

5. Save and Close 

*Note. In the command you may specify several Custom Incident Attributes (CIAs), the list of available CIAs is found in the "Help for Administrators" guide available to download at http://support.openview.hp.com/selfsolve/manuals
In the command example the following CIA is used: $snn. This indicates the name attribute of the incident's source node.

==================================================
==================================================
A couple of mail examples below:

# Example 1 - Simple:
echo "This is the body."| mailx -s "mailx Test1"
jsmith@abc.com

For examples 2 and 3, you can create an script and then call the it from the NNMi command field.

# Example 2 - Using Variables:
SUBJECT="mailx Test2"
EMAIL_ADDRESS="
jsmith@abc.com"
BODY="This is the body of the message."

echo "$BODY" | mailx -s "$SUBJECT" "$EMAIL_ADDRESS"

# Example 3 - Attached File:
SUBJECT="mailx Test3"
EMAIL_ADDRESS="
jsmith@abc.com"
BODY="This is the body of the message."
ATTACHED_FILE="/etc/hosts"

cat "$ATTACHED_FILE" | mailx -s "$SUBJECT" "$EMAIL_ADDRESS

 

http://support.openview.hp.com/selfsolve/document/KM1154783?searchIdentifier=-47af8070%3a138264e3583%3a71e&resultType=document&documentURL=KM1154783&resultsURL=%2fselfsolve%2fdocuments&allowReturn=true

 

Hope this helps,

//Add this to "OnDomLoad" event