Enterprise Integration Zone is brought to you in partnership with:

Nahuel is an electrical engineer turned Software Developer who loves OOD and Java. In his spare time he enjoys clay sculpting, reading novels, and even a bit of carpentry. Nahuel is a DZone MVB and is not an employee of DZone and has posted 2 posts at DZone. You can read more from them at their website. View Full User Profile

Trap your Alerts: An SNMP How-to using Java and Mule Enterprise Console

02.22.2013
| 1819 views |
  • submit to reddit

Customer stories series: alerts

Nagios

Motivation

We are evaluating using Nagios or a similar Big Brother Enterprise solution for displaying information about our many Enterprise Mule instances, applications and the status of our production and staging environments. The only sure thing is that we presented a budget for buying a couple of 55” monitors and were approved. Pure awesomeness!

First solution: Do it yourself

This is complicated. We would have to hire a Java programmer to develop an agent to gather statistics from servers distributed in different geographical zones. Pretty heavy stuff. The project would take a while to complete. And once that is done, we would have to start worrying about upgrades, deployment of the agent, and paperwork. We are using a waterfall cycle. You know the pain.

Second [selected] solution: Take advantage of native Mule component

We have expertise on our own infrastructure. We know how to handle Big Brother issues/configuration/maintenance. So what does the Mule team have to offer for gathering statistics about distributed Servers, apps and their corresponding status (among other things)?

MMC

We took a look at two possible approaches:

After comparing capabilities of both systems, we decided to go for the alerts. They are a better match for our needs: Notifications in almost real time for environment changes. For example:

  • Memory usage, server up, server down, etc
  • Log entries about specific Exceptions and/or information (by using regular expressions)
  • JMX stuff
  • Etc, etc.
MMC SNMP Alert Definition screenshot Ah! How do we process the info? At first we thought about email alerts, but then we realized that trapping SNMP messages with our existing infrastructure was the way to go with Big Brother (in particular with ).

If you want to implement your own SNMP server or you want to set up a suite of integration tests, here is a basic implementation that allows you to trap MMC alerts.

Basic SNMP server implementation to trap MMC alerts

Here you can find a Java barebones implementation of an SNMP server optimized for MMC. A listener calls a method when a message arrives. There are two flavors of SNMP listeners: Version 1/2c (without authentication) and version 3 (with authentication).

Once you instantiate the class by using one of the static methods (if you use the secure version, user, pass and passphrase will be requested), a listener will be binded on localhost to a port of your choice. After that, each time an alert is trapped, processPdu(…) will add the alert to an internal list for asynchronous retrieval (when getPduListAndClear() is called).

The SNMP framework used is SNMP4J, which is also an open source project.
Published at DZone with permission of Nahuel Dalla Vecchia, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)