H's Blog A good shell is the best user interface.

19Aug/100

SNMP Monitoring for Java VM

SNMP is not really simple, but quite a useful protocol, if you want to run standard monitoring tools like Nagios, Zero RRD or Cacti.
Even though Java offers JMX for runtime information like thread and memory consumption, you can also use SNMP to read at least a subset.
In my opinion usage of a standard monitoring tool has several advantages over JMX-based visualization in jconsole or Lambda Probe:

  • Statistics fit into centralized reporting, e.g. for SLAs.
  • The tools are independent of the Java VM. If the VM freezes, the history is still available


First you need to enable the SNMP Agent in your Java VM. Please find the details here. This is only an outline:

  • Prepare an ACL configuration at $JAVA_HOME/lib/management/snmp.acl. On Sun's Java 6 for Ubuntu 10.04 64 Bit you will find these files in the package ia32-sun-java6-bin.
  • Use the following options on the command line to enable SNMP:
    -Dcom.sun.management.snmp.port=7667
    -Dcom.sun.management.snmp.acl.file=$JAVA_HOME/lib/management/snmp.acl
    

If you really put the snmp.acl at $JAVA_HOME/lib/management, it's very likely, you will not need to specify the com.sun.management.snmp.acl.file option.

Now you are ready to read the internal state by using SNMP:

  • Zero Agent's module for Java SNMP just needs the port specified in conf/enabled/JavaSNMP.conf.
  • Please find some available OIDs in the source code of JavaSNMP.pm
  • The full list of available values is included in the following MIB.
25Jul/102

Cacti at Home (DD-WRT)

I recently used my MRTG to analyse some network problems at home. Since zooming felt not easy enough, I installed Cacti to monitor my DD-WRT interfaces (LAN, WLAN, DSL).

Now the only problem are the enforced downtimes of my main system in the context of Green IT. But for the usual request like Why is the internet currently so damn slow and unstable? I can use the nice reporting features of Cacti instead of BOFH-style excuses to explain that.
I just had to map the router's devices eth0, eth1, ppp0 (Linksys WRT54G/GL/GS) to some graphs (eth0/LAN, eth1/Wireless, ppp0/DSL).
Since DD-WRT is Linux-based, CPU Usage and Load Average will also work on that device.