Cover V14, i11

Article
Figure 1

nov2005.tar

Convert SNMP Traps to RSS

Fabian Salamanca

In today's networked environments, network management is a key process for day-to-day operations. Most modern companies are involved with telecommunications in one or more ways, so telecommunications concepts will be used for the convenience of this article, in which I'll show the implementation of an XML/RSS northbound interface for OpenNMS.

The International Telecommunications Union defines the Telecommunications Management Network (TMN) model for a structured way to organize and manage networks including the top-level business overview (Figure 1). This model is a simplified overview; within each level is a complex world worthy of an entire book.

Why should IT managers worry about a Network Management model? Even in small companies, it can reduce costs and streamline operations, simply because having a structured and organized way to do things saves money and time for everyone and in any situation.

The Network Management Levels

The first level defines the objects to be managed in the first place, so it is the base on which a management infrastructure should be built. The second level defines the ways in you can work with a networked element (e.g., a Web server) from an SSH session to an Element Management Console.

The third level is related to how you can manage your network topology, and it depends on the second level (which in turn depends on the first level) to build a network-wise view of your infrastructure. This is where you get information about WAN and LAN topologies, network maps, network statistics, etc. Simple Network Management Protocol (SNMP) is used for the operation, administration, and maintenance (OAM) of networked objects, from printers to routers to cluster computers. It can be used to query and configure network elements, build maps, create a centralized network database, and a plethora of other useful activities.

The fourth and fifth levels talk about service and business levels, and they are used not only for networking but for the core business of your company as well.

Northbound Interfaces

Northbound interfaces link an application from any specific layer with the upper ones. The most common ones link third-layer applications (Network Management) with service and business management infrastructure (e.g., operating systems and support (OSS), business systems and support (BSS), CRMs, ERPs, etc.), and they include a lot of implementations from plain files via FTP or ODBC/JDBC database access to CORBA, CMIP, XML, etc. In the past, the standard tools were expensive and difficult to maintain and almost all of them needed large and expensive RISC platforms.

OpenNMS

OpenNMS is an open source way to get the job done in a low-budget situation. It runs in your favorite Unix-like operating system using the familiar i686 (500 MHz or better) architecture with 512 MB RAM. The recommended platform is the one you are used to managing, because you will need to install several tools.

OpenNMS is a Network Management System based in SNMP and is able to query Web servers, SMB servers, SSH services, network interfaces, create an assets database, etc. It was chosen to be the SNMP engine because of its open source license, which allowed for free testing and implementation. OpenNMS uses a PostgreSQL database, for which a lot of documentation is available.

SNMP Traps to RSS

The Trap2RSS project aims to export information from an SNMP network manager using RSS, because is easier to find a news/RSS reader than installing a client, which may also require a license fee. Sometimes our staff doesn't need all the features (most of the time, alarms and events information are enough), and using RSS may offer a cheap and easy implementation of an XML OSS (Operating Systems and Support) northbound interface.

Installation

The tools needed are available for various Linux distributions, BSD Unices, Solaris, etc. Red Hat's RPM-based distribution will be used for this article, specifically CentOS 4, but you may find a lot of documentation for other operating systems.

The OpenNMS installation is beyond the scope of this article, so please refer to their Web site for the official documentation. The following packages are required to run OpenNMS:

  • PostgreSQL
  • RRDTool
  • Java (the full SDK, not just the JRE)
  • Tomcat 4
  • OpenNMS RPM for your distribution

PostgreSQL

PostgreSQL should be included with the operating system; if not, install from the OS media. Install your Fedora/Red Hat with server support. You'll need PostgreSQL so check your distro-installed PostgreSQL's RPM. As root, type:

[root@localhost root]# rpm -qa | grep postgre
Do the same to check whether you have Perl installed.

Now create the PostgreSQL database:

[root@localhost root]# su - postgres

-bash-3.00$ createdb opennms
-bash-3.00$ createuser opennms
-bash-3.00$ cd data
Edit the "postgresql.conf" file and set tcpip_socket = true, max_connections = 256, and shared_buffers = 1024.

Then start the postgresql service:

-bash-3.00$ exit
[root@localhost root]# service postgresql start
RRDTool

Next, you'll need RRDTool; fetch the RPM from:

http://fr.rpmfind.net/linux/RPM/dag/rhel/4/i386/ \
  rrdtool-1.0.49-2.2.el4.rf.i386.html
and type the well-known command:

[root@localhost root]# rpm -Uvh rrdtool-1.0.49-2.2.el4.rf.i386.rpm

[root@localhost root]# rpm -qa | grep perl
Java 1.4.2 SDK

You'll need to install Java 1.4.2 SDK, not just the JRE. You can obtain a copy from Sun's Java Web page:

http://java.sun.com
You'll download a bin file (the installer) from which you'll need to add execution permissions:

[root@localhost root]# chmod +x j2sdk1.4.2*.bin
Tomcat

Tomcat is an Apache project to host JSP Web pages, and there are several tomcat4 RPMs for an easy installation:

http://jakarta.apache.org/tomcat
You'll need to download tomcat4-4.1.18-full.1jpp.noarch.rpm and tomcat4-webapps-4.1.18-full.1jpp.noarch.rpm from the following site:

ftp://ftp.opennms.org/pub/dependencies/tomcat4/
Also, you'll need to download the OpenNMS RPM for your distribution. Again, OpenNMS installation is beyond the scope of this article, so refer to its Web site for documentation. You'll need to download the following RPMs from http://www.opennms.org:

opennms-1.2.3-1_<distro>.i386.rpm
opennms-docs-1.2.3-1_<distro>.i386.rpm
opennms-webapp-1.2.3-1_<distro>.i386.rpm
where "<distro>" may be rhel4, fc3, etc.

Trap2rss

Now let's look at the trap2rss installation. We'll start with Perl's CPAN repository; you'll need the XML::RSS module:

[root@localhost root]# perl -MCPAN -e 'shell'

cpan> install XML::RSS
If this is the first time you've used CPAN, you'll pass through a series of questions before reaching the cpan> prompt. The defaults should be okay.

Next, we will need a standard Apache installation. If you chose a "server" install for your Fedora/Red Hat, you should already have it installed, and most standard installations include CGI support.

Now let's download the trap2rss app from SourceForge.net:

https://sourceforge.net/project/showfiles.php?group_id=142793
The latest version as of this writing is 0.1.1.

Extract all files to your Apache's CGI directory, for example, /var/www/cgi-bin:

[root@localhost root]# cd /var/www/cgi-bin

[root@localhost cgi-bin]# tar xvfz \
  <path-to-trap2rss>/trap2rss-0.1.1.tgz
  
Fire It Up

If you've made it this far, then you are ready to go. Let's fire it up!

[root@localhost root]# service tomcat4 start
[root@localhost root]# service opennms start
[root@localhost root]# service httpd start
Point your news/RSS reader to:

http://<ip.of.your.opennms-server>/cgi-bin/trap2rss.pl
http://<ip.of.your.opennms-server>/cgi-bin/inventory2rss.pl
If you have an OSS/BSS system, you may develop an XML/RSS reader to let it access alarms and inventory from your OpenNMS database.

If you need something different from what these scripts offer, look into the OpenNMS database and sort the tables as you need them. So, in the trap2rss package, in extractalarms.pl and extractinventory.pl, you'll need to replace the line that queries the OpenNMS database. For example, in extractalarms.pl, you have:

my $query = $conn->prepare (
        "SELECT numericmsg,notifyid,pagetime,respondtime, \
         subject,textmsg from notifications"
        );
You may change the order of the fields and merge the inventory and alarms queries in one step (it may be more useful to have them in separate processes), then create your own PL/SQL statement for complex queries, etc.

You may also change the RSS version to address the one of your clients' (in the trap2rss.pl and inventory2rss.pl files):

my $rss = new XML::RSS (version => '2.0');
Conclusion

If your vendor does not provide an open Network Management System, or if you are offered an expensive solution for a northbound interface, you should try this implementation to obtain at least the alarms and inventory from your SNMP network elements in an easy, open, and free (as in freedom and as in free beer) implementation.

In this article, I have shown how to set up an XML/RSS northbound interface for OpenNMS. I hope you find it useful and easy to implement. If you have any comments and suggestions (trap2rss is still under development), please don't hesitate to contact me.

Fabian Salamanca has a bachelor's degree in Communications and Electronics Engineering. He has been working with network managers, routers, Unix, and Linux servers for more than five years and currently works as a Network Management Systems expert for Latinamerica in Alcatel, Mexico. He and his wife live in Mexico City. He can be reached at: fsalaman@gmail.com.