Sunday, July 12, 2009

Shrinking combo boxes

It seemed a simple enough requirement: just shrink the fonts of my three JComboBoxes so they would fit onto my teeny weeny applet:

But, to do that you need to create your own list cell renderer, which returns a JLabel whose font is set to 9.0 points. Also, you have to change the font of the JComboBox itself, or IT will be 12pt. The result is readable and keeps the component small.

Wednesday, July 8, 2009

SNMP Discovery

SNMP is great until you realise that the MIBs installed on a particular machine may not all be the same. What is needed is an automated discovery technique so that the user can choose, from a palette of available options, which SNMP value should be monitored by the graph. In fact, we also need to greatly reduce the number of available values, since most of them are strings or static numbers such as the number of CPUs or ethernet interface cards. What the user wants to see reflected in the graph are numbers that change, and there aren't so many of those for any given machine. Also he/she wants to monitor specific applications currently running on the machines, and for that we also need dynamic discovery.

So, my idea was to provide a default MIB on the monitoring machine. This would be loaded by the applet locally (from the same directory) and then each value searched for on the currently selected host. If found, it will be entered in the menus. And this is the problem. To avoid multiple hierarchies in the menus I opted for a simple design with two "combo boxes". The left hand combo box contains the siblings of the parent of the currently selected value. And the right hand combo shows the siblings of the current selection, which is highlighted, say, by italics or bold.

  1. To go down the hierarchy the user chooses a value on the right. If that has children, then the right menu moves to the left and the selected element's children takes its place on the right. The new selected element is the first child. If we are already at a leaf node then all we can do is choose another leaf. Otherwise nothing happens.
  2. To go up the hierarchy the user chooses a value on the left hand combo. The contents of the left combo moves to the right. The previous parent becomes the selected item, and its parents get displayed on the left, if they can. Otherwise nothing happens.

Simple. The user only sees part of the available hierarchy at any one time. Like those menus you get on hp printers. Except no special buttons to remember for up and down.

Thursday, July 2, 2009

Stopping and Starting

Stopping and then restarting wasn't working as expected. It defaulted back to PING whereas it ought to have saved the previous method and retried that. So it needed a new parameter to the creation function of Graph.

PING continuing after switch to HTTP

A nasty problem arose yesterday, only just solved. When the user switched from PING to HTTP the graph drew at the bottom, not at the top as it was supposed. The reason was that residual PING results were making their way back into the graph, keeping the maximum artificially high. The reason was that the graph sub-panel, which controlled the generation of probe threads that did the actual PINGs or HTTPs queries, was getting duplicated and replaced but not destroyed every time the graph got resized. This was caused by separating off the initialise code for Graph into a separate routine and rerunning it whenever a resize occurred. The side effect was duplication of threads that couldn't be killed. Doh!

Wednesday, July 1, 2009

Slow DNS lookup

I traced the slowness in the Monitor applet down to the DNS lookup performed by currAddr.getHostName(), where currAddr is an InetAddress object. This looks up the domain name if the address was not created with it already, in which case it just remembers it. So if I cycle through the ip-addresses on a C-class subnet and I find one that is reachable after 5 milliseconds, I need to do a reverse DNS lookup to get the domain name. But if it doesn't have one it takes 15 seconds before it times out. Strangely, it then changes the ip-address to instead of the / it started with. (Don't know what the initial "/" is for). What I want to do is specify a timeout of say 10 milliseconds for lookup to succeed within. After that I am happy to go with the numerical address. But you can't do it, apparently.

SNMP fails because it needs SNMP library

Although I provided the SNMP library 1.4.2 for compilation it isn't included in the applet, so it falls over. Doh! OK, I fixed that by including those class files in the jar for the applet, BUT when I run a simple SNMP query (free RAM) it fails on the Windows XP client. Why?