Java Client: Realm Monitor
Monitors a Universal Messaging Realm and output results to CSV files.
Usage
java RealmMonitor <rnames> [config file]
<Required Parameters>
<rname> : comma separated list of rnames to monitor.
[Optional Parameters]
[config file] : configuration file location e.g. c:\\config.txt
All other parameters can be specified in the config file.
If realm is clustered then other realms in cluster will
be found automatically.
Application Source Code
Description of Classes and Output
Contained within the application are 5 separate classes each set up to monitor different aspects of a Universal Messaging Realm:
The application takes 2 arguments:
1. RNAMEs
Comma separated list of RNAMEs of the realms to monitor.
If the realm is part of a cluster, the application will also monitor the cluster members so there is no need to list the RNAMEs of the other cluster members.
2. Configuration file
[optional] the location of the configuration file (including the name of the file).
If this is not specified, a default file will be created.
Each monitor will output different information and at different intervals. The information to be output can be specified in the 'methods' field in the configuration file for each monitor. The data is written to CSV files so that it can be easily plugged into graphing tools or other monitoring applications. Most of the monitors will only output data if a certain condition is met for example the log monitor will only write data if a keyword is found in a line of the Universal Messaging Realm log. The realm monitor on the other hand will constantly output data to the CSV every X seconds. If a realm goes down, the realm monitor will output 0s which will make any problems apparent if the data is put into a graph.
Configuration File
The configuration file provides flexibility to change when and what data is output for each monitor. The application will generate a default configuration file if no command line argument is specified. This default file contains all the necessary parameters to start monitoring but all parameters are customisable. Each monitor has different triggers for when to output data. These triggers can all be specified in this file. More detail on the monitor specific parameters can be found in the relevant sections below. You can also specify the working directory for the tests [default: ./RealmMonitorOut/] and which tests to run.
'methods' parameter
Each monitor requires this parameter to be set in the configuration file. This is a comma separated list of method names to be invoked on the object that the monitor is observing. The result of each of these methods will be output to the CSV file under the corresponding heading in the 'headings' parameter.
For example the connection monitor is monitoring connections so will invoke the methods on the nConnectionDetails object. You can specify any methods here that are a member of the nConnectionDetails class. It is possible that the return type of these methods will not be a type that is easily represented as a string or you may wish to display the object in a certain way. Most of these cases have been dealt with already but in order to change the behaviour you can simply override the method name in the relevant monitor class. For example the channel monitor invokes the methods on nLeafNode which has a method called getUsedSpace. getUsedSpace returns a long representing the number of bytes used, however this application will return the used space in kilobytes because the method is overridden:
public String getUsedSpace(Object o){
long used = ((nLeafNode)o).getUsedSpace();
used = used/1024;
return used+"";
}
The above method overrides the getUsedSpace method on the nLeafNode. By simply creating this method inside the ChannelMonitor class, whenever getUsedSpace is required, this method will be called instead with the nLeafNode as a parameter.
Connection Monitor
The connection monitor maintains a list of the current connections to the realm. Every x seconds the monitor will check each connection for potential problems and write the details of that connection to the CSV file if any trigger is hit.
There are two triggers currently available:
maxQueuedEvents - maximum number of events allowed to be queued for a connection before the monitor will output to the CSV
maxTimeOfLastTransmit - maximum time taken to transmit the last event.
This monitor invokes the method in the 'methods' parameter on the nConnectionDetails object.
Realm Monitor
The realm monitor prints to the CSV file every x seconds (configurable by the refreshRate parameter). There are no triggers for this monitor as the information should be available at all times. If no data is available (realm is down) then by default the monitor will output 0s to the CSV.
This monitor invokes the method in the 'methods' parameter on the nRealmNode object.
Thread Monitor
The thread monitor constantly checks the thread pools for unexpected values. There are 2 triggers which will cause the monitor to write to the CSV:
maxQueueSize - if the number of queued tasks in the thread pool exceeds this value then the information on this tread pool will be output to the CSV
minIdle - the minimum number of idle threads available before the monitor will output to the CSV
This monitor invokes the method in the 'methods' parameter on the nThreadPool object.
Log Monitor
This monitor listens to the Universal Messaging log and will write to the CSV whenever any line of the log contains a keyword. The list of keywords can be specified in the config file.
The 'methods' parameter in the configuration file will be invoked on the LogMonitor class or the enclosing RealmMonitor class e.g. getTime.
Channel Monitor
The channel monitor keeps track of the current channels and queues on the realm. If any triggers are hit for a leaf node then the details of that leaf node are output to the CSV.
There are many triggers that can be set for this monitor. For example there is a parameter called 'minCurrentCons' and an associated 'maxCurrentCons'. If the number of current connections falls outside of this range then the details of the leaf node are printed to the CSV.
This monitor invokes the method in the 'methods' parameter on the nLeafNode object.