I thought I would share command line (action I )came up with for having HP Open View NNM send email notifications based on the various SNMP traps received by the management station.
blat.exe -server smtp.acme.org -to Alert@acme.org -cc HelpDesk@acme.org -html -subject "HPOV: UPS on battery ($snn)" -body "<html><body><p style=font-family:Verdana;font-size:12px;font-style:normal;font-weight:normal;><b>HP Open View NNM Alarm Incident Report</b><br /><br />||<b>Date:</b> %date% %time% ($fot)<br />|<b>Alarm:</b> UPS on battery - power failure($name)<br />|<b>Node:</b> $snn($sln)<br />|<b>IP:</b> $mga ($oma)<br />|<b>Contact:</b> $sct<br />|<b>Location:</b> $slc<br /><br />|<b>Notes:</b> generated by HP Open View NNM 9i management server.<br /></p>|</body></html>"
The command line above will utilize blat to send an HTML formatted email message to alert@acme.org with a copy to helpdesk@acme.org with the body looking something similar to the figure to the figure to the right. I’ve sanitized the screenshot to protect the organization I’m currently employed with. The example above is for the SNMP trap ‘upsOnBattery’ while the image to the right is an example of the SNMP trap ‘powerRestored’. You’ll notice the | in the command line is interpreted as a CR/LF by NNM. Here are some of the parameters used in the above example;
- $ssn – node name of the object sending the SNMP trap
- $fot – first occurence time
- $name – OID name of the trap received
- $sln – DNS name of the node
- $mga – management IP address
- $oma – alternative management IP address
- $sct – contact information for the object as stored in sysContact.0
- $slc – location information for the object as stored in sysLocation.0
While it wasn’t too hard it did take some time to get all the formatting down and get it working reliably.
Cheers!
Chris says
I was unable to get this to work at all for NNMi 9.1, was there anything else you did to allow the command line to send in html style? I am able to send a text style notification but could not get this html version to work.
Michael McNamara says
What version of blat are you using? I’m using v2.6.2 and it works every time without fail.
When you look at the log file (incidentActions.0.0.log) what do you see happening?
Good Luck!
Chris says
I was using v.2.6.2 and could not get the html to work so I upgraded to the v2.7.5 version and I’m having the same issue. I’m using your exact html copy but I obviously replaced emails and smtp server. I’m not sure where the incident log file is located at?
Michael McNamara says
Hi Chris,
It can be in a few different locations depending on your operating system. Just search your filesystem for “incidentActions” and you should find it pretty quickly.
Also, if you run that same command from the command-line (you’ll need to replace the variables with the appropriate text) does the email come through? This will eliminate NNM from the equation. It could be your SMTP server or your client.
Good Luck!
Chris says
I was able to send the email from the command line, but when the command is ran through NNM it does not send. The log reads as a “null” status for standard output, standard error, execution status. No errors are in the log file.
Michael McNamara says
Hi Chris,
It seems you have an issue with HP NNM and not blat. I would check to make sure that you’ve enabled the action within the Incident Configuration. In the log file you should see something similar to the following (I’ve sanitized the data);
Oct 13, 2011 2:04:18.840 PM [ThreadID:11] FINE: com.hp.ov.nms.events.actionlog.ActionLogger addToProcessList:
*******************************************************************************
Command: ""blat.exe" "-server" "smtp.acme.org" "-to" "alerts@acme.org" "-html" "-subject" "HPOV: Chassis Power Supply Up (sw-icr31.hospital.acme.org)" "-body" "
HP Open View NNM Alarm Incident Report
||Date: %date% %time% (Thu Oct 13 14:04:16 EDT 2011)
|Alarm: Chassis Power Supply Up - power has been restored (RcnChasPowerSupplyUp)
|Node: sw-icr31.hospital.acme.org(10.1.255.4)
|IP: 10.1.20.176 (null)
|Contact: Technology Infrastructure Team
|Location: Hospital 1st Floor (ICR31)
|Notes: generated by HP Open View NNM 9i management server MDCHPOV1
|""
Started at 10/13/11 2:04 PM
Incident Name: RcnChasPowerSupplyUp
Incident UUID: b6ad3d6b-6ba2-48bf-839a-4c1fe595705a
Command Type: ScriptOrExecutable
Lifecycle state: com.hp.nms.incident.lifecycle.Registered
Exit Code: 0
Standard Output: null
Standard Error: null
Execution Status: null
Ran for 0 milliseconds
*******************************************************************************
Good Luck!
Ryan says
Hi Chris,
thanks for the script. Its working on my end.
Just wondering, is it possible to generate also an alert if the device is UP? if yes, what will be the event configuration? i dont see any NodeUp/InterfaceUp in NNMi 9.1
Cheers!
Michael McNamara says
Hi Ryan,
I’m happy to hear you found the script useful. You just need to locate the HP OV event for ‘Node Down’ and then apply whatever action you’d like.
Good Luck!
Ryan says
Hi Chris,
Just want to ask. For example, you have hundreds of servers/devices that you manage around the world. Is it possible to indicate in the alert what NODE GROUP do they belong?
DATE:
ALARM:
NODE:
IP:
NODE GROUP: ?????
Michael McNamara says
Hi Ryan,
The script is just processing variables that are passed from HP OpenView. So if HP OpenView can pass the variable you can certainly include it.
Good Luck!
Chris says
Yeah that is the same log I receive, but unfortunately I never receive the actual email.
Command: “”blat.exe” “-server” “smtp.email.com” “-f” “NNM_Test@company.com” “-to” “worker@company.com” “-html” “-subject” “HPOV: UPS on battery oak-c10s2” “-body” “HP Open View NNM Alarm Incident Report||Date
: %date% %time% Thu Oct 20 07:28:21 CDT 2011 |Alarm: UPS on battery – power failure NodeDown |Node: oak-c10s2 \”Invalid or unknown cia sl\”
n |IP: 10.244.129.102 |Contact: 116805 |Location: New Headquarters |Notes: gener
ated by HP NNM9i|””
Started at 10/20/11 8:45 AM
Incident Name: NodeDown
Incident UUID: 58b91a99-af9b-40b1-a9c7-7be41dd58ec4
Command Type: ScriptOrExecutable
Lifecycle state: com.hp.nms.incident.lifecycle.Closed
Exit Code: 0
Standard Output: null
Standard Error: null
Execution Status: null
Ran for 0 milliseconds
Ramees Ahamed says
Hi Michael,
I have installed HP NNM 9.10 and now I want to get the incidents in my mailbox.
Kindly tell me the step by step procedure to Configure Blat.
Michael McNamara says
Hi Ramees,
You’ll find all the instructions you need in the HP manuals… you can use the information I’ve shared above in those steps to get blat working.
Good Luck!
Ramees Ahamed says
Hi Michael,
I have read the above instructions and I want to know where to place the extracted blat file in the HP NNM Server(Windows) and where to specify the Incident Action in NNM.
Michael McNamara says
I believe I ran the Blat installer… but you can put the blat.exe in any directory that’s included in your (search) PATH statement. You can find your PATH by issuing “path” from a command window.
I believe I’ve placed it in C:\Windows\System32 on some previous installations.
Cheers!
Jeremy says
What is the file supposed to be saved as? HTML, bat, ovpl ???
Jeremy says
I get the emails in setting this up as a .bat but all of the $ fields are exactly as they appear in the file. I’m using nnmsnmpnotify.ovpl to trip the snmp traps that I’m setting up email for but the node names and traps names etc are not coming in.