Automatic Map Creation

From OpenNMS
Jump to navigation Jump to search

The specification for this story is here.

Automatic Map Creation

The map provisioning adapter and the link provisioning adapter work together to automatically create maps when nodes are provisioned into OpenNMS. This removes the drudgery of manually creating them via the web ui and also allows new nodes to be automatically added to maps as they are provisioned.

In addition, host naming conventions can be used to determine when pairs of system should be linked via an otherwise undiscoverable link.

Installation

The map provisioning adapter and the link provisioning apapter are provisioning plugins. To install them install the opennms-plugin-provisioning-map and opennms-plugin-provisioning-link packages.

sudo apt-get install opennms-plugin-provisioning-map

sudo apt-get install opennms-plugin-provisioning-link

Configuration

Provisioning plugins are automatically detected by Provisiond on startup so all that is necessary is to edit the configurations for each of the plugins.

Map Adapter Configuration

The structure of the automatic maps is defined in ${opennms.home}/etc/mapsadapter-configuration.xml. And defines configuration based maps and submaps. Node packages define 'groups' of elements to be added to submaps based on OpenNMS filtering expressions.

The sample mapsadapter-configuration.xml below does the following:

  1. Creates toplevel map called Sites containing icons Site A and Site B
  2. Creates maps associated with each of the 'Site' icons called site-a' and 'site-b respectively.
  3. Adds all of the nodes while nodeLabels matching site-a-* and site-b-* to the appropriate maps.
Map Adapter Configuration Example
 <?xml version="1.0"?> 
 <maps-adapter-configuration element-dimension="50"> 
   <package name="site-a"> 
     <filter>nodeLabel like 'site-a-%'</filter> 
     <include-range begin="1.1.1.1" end="254.254.254.254" /> 
   </package> 
   <package name="site-b"> 
     <filter>nodeLabel like 'site-b-%'</filter> 
     <include-range begin="1.1.1.1" end="254.254.254.254" /> 
   </package> 
   <cmaps> 
     <cmap mapName="Sites" mapOwner="admin" mapAccess="RW" mapWidth="800" mapHeight="600"> 
       <csubmap name="site-a" label="Site A" x="485" y="350" /> 
       <csubmap name="site-b" label="Site B" x="485" y="450" /> 
     </cmap> 
     <cmap mapName="site-a" mapOwner="admin" mapAccess="RW" mapWidth="800" mapHeight="600"> 
       <celement package="site-a" icon="switch"/> 
     </cmap> 
     <cmap mapName="site-b" mapOwner="admin" mapAccess="RW" mapWidth="800" mapHeight="600"> 
       <celement package="site-b" icon="switch"/> 
     </cmap> 
   </cmaps>  
 </maps-adapter-configuration>


Link Adapter Configuration

The link provisioning adapters configurtion is in ${opennms.home}/etc/link-adapter-configuration.xml.

The idea here is to create links based on the nodeLabel for the node. The below configuration will create links between nodes that with nodeLabels as follows:

site-a-to-site-b-link AND site-b-to-site-a-link

It does this by matching one regular expression and building the other label using regex matching groups. If both nodes exist then a link is created.

Note: The xmlns is required

Link Adapter Configuration Example
 <?xml version="1.0"?> 
 <link-adapter-configuration xmlns="http://xmlns.opennms.org/xsd/config/map-link-adapter"> 
   <for match="site-([a-z])-site-([a-z])-link">
     <link>site-$2-site-$1-link</link> 
   </for> 
   ... 
 </link-adapter-configuration> 

which means

if a nodeA matches:

site-([a-z])-site-([a-z])-link

and nodeB exists that matches:

site-$2-site-$1-link

where $n is the nth matching group from the regex for nodeA, then make a link from nodeA to nodeB.

Note: Use the node whose name comes first in String order as the parent node for the link. If a pair already has link the link is left alone.

Provision Nodes

To use the examples above provision some nodes using the conventions described. Provisioning the following nodes will exercise both the map and link proivioning adapters.

 site-a-switch
 site-a-site-b-link
 site-b-switch
 site-b-site-a-link
 

View the Map

After provisioning has been completed and the mapsadapter has run, Maps should be create with hierarchy the resembles the following.

 Map - Sites
  | 
  --> Site A (linked to Site B) 
  | | 
  | -->Submap site-a 
  |       |
  |       |---> site-a-switch 
  |       |
  |       |---> site-a-site-b-link 
  | 
  --> Site B (linked to Site A) 
         | 
         -->Submap site-b
                |
                | --> site-b-switch 
                |
                | --> site-b-site-a-link



Map Link Context Menus

New on in 1.7.8 we have added support for context menus for links between two nodes. If you've followed the above configuration and open the 'Sites' map you can double click on the link between 'Site A' and 'Site B' and open the context menu. The context menu will display a menu for each node. 'Site A' and 'Site B' with actions below, such as ping, traceroute, events and resource graphs are just a couple of the options with the ability to customize all of the options you want in the context menu through the map.properties file.

Configuring the Context Menu

All configuration related to the context menus for the map are located in the map.properties section. Below you will find the context menu section

############################################################################ 
## C O N T E X T M E N U 
# 
############################################################################ 
# - A comma-separated list of context menu commands (skipped if contextmenu is disabled): 
# cmenu.commands=COMMAND1,COMMAND2,...,COMMANDN 
# for each command: 
# cmenu.{COMMAND1}.link: link to the page to open (you can use the special words 'ELEMENT_ID' and 'ELEMENT_LABEL' 
# to use the selected map element's id or label as argument of the linked page) 
# cmenu.{COMMAND1}.params: (javascript window.open() ) params for the window containing the page 
# - to insert a separator in the context menu, use the character '-' as command and omit link and params. 
# - link is a parameter mandatory, params is optional 
############################################################################ 
# Add context menu item here 
# uncomment this to enable 'telnet' in context menu 
#cmenu.commands=Node,-,Telnet,Ping,Traceroute,-,Alarms,Events,Resource%20Graphs 
# comment this if you want to enable 'telnet' item in context menu 
cmenu.commands=Node,-,Ping,Traceroute,-,Alarms,Events,Resource%20Graphs 
# Context menu node Item 
cmenu.Node.link=element/node.jsp?node=ELEMENT_ID 
cmenu.Node.params=toolbar,width=1280,height=800, left=0, top=0, scrollbars=1, resizable=1 
# Context Menu Telnet Item, uncomment to enable Telnet from map context menu 
#cmenu.Telnet.link=telnet://ELEMENT_LABEL 
cmenu.Ping.link=map/response/ping.jsp?node=ELEMENT_ID 
# use this on solaris 
#cmenu.Ping.link=map/response/ping.jsp?node=ELEMENT_ID&solaris=true 
cmenu.Ping.params=toolbar,width=300,height=300, left=0, top=0, scrollbars=1, resizable=1 
cmenu.Traceroute.link=map/response/traceroute.jsp?node=ELEMENT_ID 
cmenu.Traceroute.params=toolbar,width=300,height=300, left=0, top=0, scrollbars=1, resizable=1 
cmenu.Alarms.link=alarm/list.htm?sortby=id&acktype=unack&limit=20&filter=node%3DELEMENT_ID 
cmenu.Alarms.params=toolbar,width=1280,height=800, left=0, top=0, scrollbars=1, resizable=1 
cmenu.Events.link=event/list?filter=node%3DELEMENT_ID 
cmenu.Events.params=toolbar,width=1280,height=800, left=0, top=0, scrollbars=1, resizable=1 
cmenu.Resource%20Graphs.link=graph/chooseresource.htm?parentResourceType=node&parentResource=ELEMENT_ID&reports=all 
cmenu.Resource%20Graphs.params=toolbar,width=1280,height=800, left=0, top=0, scrollbars=1, resizable=1 

For this example we'll add ssh and http to the context menu. In the map.properties file find the above context menu area and add the following.

cmenu.commands=ssh,http,-,Node,-,Ping,Traceroute,-,Alarms,Events,Resource%20Graphs 
cmenu.ssh.link=ssh://ELEMENT_LABEL 
cmenu.http.link=http://ELEMENT_LABEL 

You will need to restart OpenNMS to see the change but the next time that you go back to the map and double click the link you will see ssh and http above Node in the context menu.

ssh
http
------------
Node
------------
Ping
Traceroute
------------
Alarms 
Events
Resource Graphs

This is a simple diagram of what you will see.

Configuration Reload

Like many of the daemon configuration in the 1.7 branch, the configurations are reloadable without having to restart OpenNMS, using the reloadDaemonConfig uei:

To reload the mapsadapter-configuration.xml run:

/opt/opennms/bin/send-event.pl uei.opennms.org/internal/reloadDaemonConfig --parm 'daemonName Provisiond.MapProvisioningAdapter'

This means that you don't have to restart OpenNMS every time you update the configuration.