Integrate HP OpenView
Subscribe

From OpenNMS

Jump to: navigation, search

Contents

What is HP OpenView?

HP OpenView isn't a product, it's a suite of products.

HP OpenView Products:

  • Network Node Manager (NNM) ⇒ SNMP polling
  • OpenView Operations for UNIX(OVOU) ⇒ Server Management/Centralized Alarm Browser
  • Service Desk ⇒ Ticket Management
  • others...

Forwarding traps from NNM to OpenNMS

The Problem

HP's OpenView Network Node Manager does quite well recieve traps from various sources... but once inside the traps can only be forwarded using tcp port 162 (at the reciever end) and then HP uses a propretary format.

Forwarding Alarms from OpenNMS to OVO

The key to understanding this is to understand that no forwarding is actually done; instead, OpenNMS parses events and then generates a new event with the HP OV_Agent command-line (/opt/OV/bin/OpC/opcmsg). The events are parsed by a beanshell (bsh) script contained in $OPENNMS_HOME/etc/scriptd-configuration.xml. This is based off of the EMC/Smarts integration document found elsewhere on this wiki.

Also, the code shown below is an early version. You can actually connect to the database through the OpenNMS API and grab items such as any of the Asset Information. This can be helpful if you want to assign dynamic mesasge groups based on Operating System, etc.

Pre-Requisites

There are two(2) pre-requisites for event-forwarding:

  1. HP OV_Agent installed on OpenNMS host.
  2. Network connectivity on port 383 to and from the OVO server.

HP OV_Agent

  1. Install the HP OV_Agent on the OpenNMS host. This is needed to generate traps to OVO. FIXME (explain how to do this)

Network Connectivity

  1. Allow access to and from the OpenNMS host to the OVO host on TCP port 383.

eg. OpenNMS-host:383 <==TCP==> OVO-host:383

Event Forwarding Configuration

  1. Edit the $OPENNMS_HOME/etc/scriptd-configuration.xml to look like the following. This is the code that actually generates traps sent to OVO.

NOTE: Don't forget to update the line: "openNMSServer = "server"" in the below code. Also, you will need to update the messageGroup variable to what ever you have defined in OVOU, otherwise events will not show up in the browser. You will also have to add all the nodes into the OVOU console that OpenNMS will be monitoring. Automation can be used to do this, but it is outside the scope of this document.

 <?xml version="1.0"?>
 <scriptd-configuration>
       <engine language="beanshell" className="bsh.util.BeanShellBSFEngine" extensions="bsh"/>
       <start-script language="beanshell">
               import org.opennms.protocols.snmp.SnmpPduTrap;
               import java.net.InetAddress;
               import java.net.UnknownHostException;

               log = bsf.lookupBean("log");
               snmpTrapHelper = new org.opennms.netmgt.scriptd.helper.SnmpTrapHelper();
       </start-script>
       <stop-script language="beanshell">
               snmpTrapHelper.stop();
               log.debug("executing a stop script");
       </stop-script>
       <event-script language="beanshell">
       event = bsf.lookupBean("event");
       if ((event.uei.equals("uei.opennms.org/nodes/nodeUp"))
               || (event.uei.equals("uei.opennms.org/nodes/nodeDown"))
               || (event.uei.equals("uei.opennms.org/nodes/interfaceDown"))
               || (event.uei.equals("uei.opennms.org/nodes/interfaceUp"))
               || (event.uei.equals("uei.opennms.org/nodes/nodeLostService"))
               || (event.uei.equals("uei.opennms.org/nodes/nodeRegainedService"))
               || (event.uei.equals("uei.opennms.org/nodes/nodeDeleted"))
               || (event.uei.equals("uei.opennms.org/nodes/serviceDeleted"))
               || (event.uei.equals("uei.opennms.org/nodes/interfaceDeleted"))
               || (event.uei.equals("uei.opennms.org/nodes/dataCollectionFailed"))
               || (event.uei.equals("uei.opennms.org/threshold/highThresholdExceeded"))
               || (event.uei.equals("uei.opennms.org/threshold/highThresholdRearmed"))
               || (event.uei.equals("uei.opennms.org/threshold/lowThresholdExceeded"))
               || (event.uei.equals("uei.opennms.org/threshold/lowThresholdRearmed"))
               || (event.uei.equals("uei.opennms.org/nodes/thresholdingFailed"))
               || (event.uei.equals("uei.opennms.org/vendor/Cisco/traps/mteTriggerFired"))
               || (event.uei.equals("uei.opennms.org/generic/traps/SNMP_Cold_Start")))
       {
               log.debug("Forwarding an OpenNMS event.");
               openNMSServer = "server";

               // Take out tabs, new lines, multiple spaces and HTML tags.
               event.descr = event.descr.replaceAll("\\t", "").replaceAll("<.*>", "").replaceAll("\\n", " ").replaceAll("\\s+", " ");
               if (event.host != null) {
                       // Check to see if host is unresolved.host or 0.0.0.0 and then see if we can get the IP from the description
                       host = event.host;

                       if (!(event.uei.equals("uei.opennms.org/vendor/Cisco/traps/mteTriggerFired")
                            || event.uei.equals("uei.opennms.org/generic/traps/SNMP_Cold_Start"))) {
                               // Attempt to extract the IP Address out of the event description.
                               tmpMessage = event.descr.replaceAll(".* (\\d{2,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}).*", "$1");
                               if (tmpMessage != null) {
                                       try {
                                               host = InetAddress.getByName(tmpMessage).getHostName();
                                       } catch ( UnknownHostException e ) {
                                               host = tmpMessage + " (DNS lookup failed)";
                                       }
                               } else {
                                       host = openNMSServer;
                               }
                       }
                       if (host.equals("host")) {
                               host = openNMSServer;
                       } else if (host.equals("unresolved.host") || host.equals("0.0.0.0")) {
                               host = openNMSServer;
                       }

                       log.debug("This is for host " + host);
               } else {
                       host = openNMSServer;
               }
               if (event.severity != null) {
                       //normal, warning, minor, major or critical
                       severity = event.severity.toLowerCase();
                       if ( !(severity.equals("normal")
                           || severity.equals("warning")
                           || severity.equals("minor")
                           || severity.equals("major")
                           || severity.equals("critical")) ) {
                               severity = "normal";
                       }
               } else {
                       severity = "normal";
               }

               if (event.service != null) {
                       application = event.service;
               } else {
                       if (event.uei.equals("uei.opennms.org/vendor/Cisco/traps/mteTriggerFired")) {
                               log.debug("----> Going to extract the application from the varbinds from the event");
                               application = "SNMP Threshold";
                               // Get all the varbinds
                               myParms = event.parms.getParm();
                               if (myParms == null) {
                                       log.debug("Parameters null");
                               } else {
                                       // Get the first varbind value
                                       log.debug("Parameters not null");
                                       int count = myParms.length;
                                       application = application + ": " + myParms[count-2].getValue().getContent().toUpperCase();
                               }
                               log.debug("Got application of " + application);
                       } else {
                               application = "Unknown";
                       }
               }

               if (event.descr != null) {
                       if (event.uei.equals("uei.opennms.org/vendor/Cisco/traps/mteTriggerFired")) {
                               log.debug("----> Going to extract the event details from the varbinds from the event");
                               // Get all the varbinds
                               myParms = event.parms.getParm();
                               if (myParms == null) {
                                       log.debug("Paramters null");
                                       descrString = event.descr.replaceAll("^ ", "").replaceAll(" $", "");
                               } else {
                                       // Get the number of varbinds
                                       int count = myParms.length;
                                       // Get the last varbind value
                                       descrString = myParms[count-1].getValue().getContent();
                               }
                               log.debug("Got event details of " + descrString);
                       } else {
                               descrString = event.descr.replaceAll("^ ", "").replaceAll(" $", "");
                       }
               } else {
                       descrString = "No description available";
               }

               ovoCommand = new String[7];
               ovoCommand[0] = "/opt/OV/bin/OpC/opcmsg";
               ovoCommand[1] = "severity=" + severity;
               ovoCommand[2] = "application=" + application;
               ovoCommand[3] = "object=" + host;
               ovoCommand[4] = "msg_grp=EnterpriseManagement";
               ovoCommand[5] = "msg_text=" + descrString;
               ovoCommand[6] = "node=" + host;
               ovoString = "/opt/OV/bin/OpC/opcmsg severity=" + severity + " application=" + application + " object=" + host +
                 " msg_grp=Enterprise Management msg_text=" + descrString  + " node=" + host + "";
               log.debug("Going to execute: " + ovoString);
               try {
                       rt = Runtime.getRuntime();
                       // proc = rt.exec(ovoString);
                       proc = rt.exec(ovoCommand);
                       stderr = proc.getErrorStream();
                       isr = new InputStreamReader(stderr);
                       br = new BufferedReader(isr);
                       while ( (line = br.readLine()) != null)
                               log.debug("COMMAND ERROR: " + line);
                       int exitVal = proc.waitFor();
                       log.debug("Exit value: " + exitVal);
               } catch ( t ) {
                       log.debug("Execption executing OVO alert: " + t.toString());
               }
               log.debug("Done executing command");
       }
       </event-script>
 </scriptd-configuration>

The above code is highly specific for our site and will have to be changed to match your configuration. It should be trivial to modify the code to work with your OVO deployment. The code is very messy and needs to be cleaned up, but for now it should get you started.

  1. Restart OpenNMS