NagVis Integration

From OpenNMS
Jump to: navigation, search

NagVis Integration

NagVis is a map tool used for Nagios to visualize the state of hosts and services. With an additional backend, NagVis can be used to visualize the states of OpenNMS hosts and services


Some Details of the Integration of NagVis in OpenNMS

To integrate NagVis in OpenNMS we have to add some PHP classes to NagVis.

OpenNMS Backend

NagVis uses serveral backends to get the state of map objects like nodes or services(that means if the objects are UP or DOWN). For OpenNMS we added an own Backend named GlobalBackendOpenNMS.php. It gets the state of the map objects directly from the OpenNMS database.

NagVis uses hostnames to identify nodes in the system. In OpenNMS the hostname, which is the node label isn't unique. So for the backend we use a name in the following way, to indentify the single nodes:

 Nodelabel@Nodeid     for example: localhost@1

If you click on a map object (like a node or service), you should get to the OpenNMS node page. You can set the URL of such links in the NagVis configuration file. As parameter you can use the NagVis hostname, which has the form Nodelabel@Nodeid. OpenNMS needs the NodeID as parameter to show the correct node page. So we need a little peace of software, that translates Nodelabel@Nodeid to Nodeid. That ist done by the file opennms_redirect.php. As taget URL for map objects, set opennms_redirect.php like that in the NagVis configuration file:

 [paths]
 htmlcgi="/nagvis/opennms_redirect.php"
 ...
 
 [defaults]
 hosturl="[htmlcgi]?host=[host_name]"
 serviceurl="[htmlcgi]?host=[host_name]"

So, if you click on a node or service object, NagVis goes to opennms_redirect.php and gives the parameter host with the hostname to the script. By default the script redirects to the http://<host>:8980/opennms/element/node.jsp?node=<nodeid>

Authentication and Authorisation

By default, NagVis has an integrated SQlite database for authentication and authorisation of users, but you also can use own modules. We wrote an authentication and an authorisation module for the usage of the OpenNMS user database. For authentication we wrote the class CoreAuthModOpenNMS.php. It checks all user against the OpenNMS user database in /etc/opennms/users.xml. So all OpenNMS users get access to NagVis with their OpenNMS username and password. It is a readonly access to the user database from NagVis, which means, it is not possible to add or delete users in NagVis.

Authorisation is realized by the class CoreAuthorisationModOpenNMS.php. It decides between the two roles read-only access and read-write access. It checks the role of an user by reading /etc/opennms/magic-users.properties. So all users in OpenNMS with admin permissions have read-write permissions in NagVis.

To get the modules working, the classes should be copied to <NagVis-Dir>/share/server/core/classes/. To use the new modules, set up the follwing entries in the NagVis configuration file.

 [global]
 authmodule="CoreAuthModOpenNMS"
 authorisationmodule="CoreAuthorisationModOpenNMS"

The webserver users needs read access to /etc/opennms/users.xml and /etc/opennms/magic-users.properties.

Installation of NagVis for OpenNMS

We created a package of NagVis, which contains all the extensions (OpenNMS Backend, OpenNMS Authentication and Authorisation) and an adjusted NagVis configuration file. You can download NagVis with OpenNMS extensions here: NagVis 1.6.3 with OpenNMS Backend

To use NagVis with the OpenNMS Backend, you need the following packages to be installed on your system:

  • apache2
  • ibapache2-mod-php5
  • php5-sqlite
  • php5-pgsql
  • graphviz

If you use Ubuntu Server, just execute the following command:

 aptitude install apache2 libapache2-mod-php5 php5-sqlite php5-pgsql graphviz

If you use CentOS, you need additionally the package php-xml.

After that, extract the downloaded NagVis package to a directory (for example /opt)

 cp nagvis-opennms-1.6.3.tar.gz /opt
 cd /opt
 tar -xzvf nagvis-opennms-1.6.3.tar.gz

The directory /opt/nagvis/share has to be reachable by HTTP. So create the following symlink:

 ln -s /opt/nagvis/share /var/www/nagvis

Now, we need to set some permissions for NagVis:

  • /opt/nagvis and all subdirectories must be readable by the webserver user (for example www-data)
  • /opt/nagvis/etc and all subdirectories must be writable by the webserver user (for example www-data)
  • /etc/opennms/users.xml and /etc/opennms/magic-users.properties must be readable by the webserver user (for example www-data)


Standard configuration

By default we have the following configuration of NagVis in the package:

OpenNMS Backend

The OpenNMS Backend uses the following parameters to access the OpenNMS database

  • dbhost = localhost
  • dbport = 5432
  • dbname = opennms
  • dbuser = opennms
  • dbpass = opennms

You can change these items in the NagVis configuration file <NagVis-Dir>/etc/nagvis.ini.php

Authentication and Authorisationmodule

The Authentication and Authorisationmodule is set to the new OpenNMS Authentication modules:

 authmodule="CoreAuthModOpenNMS"
 authorisationmodule="CoreAuthorisationModOpenNMS"


Links in Maps to OpenNMS objects

Links in maps on OpenNMS objects are handeld by opennms_redirect.php. It redirects by default to the follwing URL: http://<HostName>:8980/opennms/element/node.jsp?

You can change this behavior in opennms_redirect.php

Integrating NagVis in OpenNMS WebUI

To integrate NagVis in OpenNMS WebUI, download the NagVis-OpenNMS WebUI extensions

In the OpenNMS WebUI directory (for example /usr/share/opennms/jetty-webapps/opennms) create a directory named nagvis and copy index.jsp from the downloaded archiv to this directory.

NagVis is now reachable in the OpenNMS WebUI by <OpenNMS-HOME>/nagvis/index.jsp

To create an own menu entry, just edit the file /usr/share/opennms/jetty-webapps/opennms/WEB-INF/dispatcher-servlet.xml and add the follwing lines:

 <bean class="org.opennms.web.navigate.LocationBasedNavBarEntry">
       <property name="name" value="NagVis Map"/>
       <property name="url" value="nagvis/index.jsp"/>
       <property name="locationMatch" value="nagvis"/>
 </bean>