uk.org.iscream.cms.server.client
Class MonitorSkeleton

java.lang.Object
  extended by java.lang.Thread
      extended by uk.org.iscream.cms.server.client.MonitorSkeleton
All Implemented Interfaces:
Runnable, PluginMonitor
Direct Known Subclasses:
CPU__Monitor, Disk__Monitor, DiskIO__Monitor, Heartbeat__Monitor, Load__Monitor, MailQ__Monitor, Memory__Monitor, NetIO__Monitor, Paging__Monitor, Process__Monitor, Queue__Monitor, Services__Monitor, Swap__Monitor, UserCount__Monitor

public abstract class MonitorSkeleton
extends Thread
implements PluginMonitor

Skeleton class for Monitors This skeleton reads packets from a queue designated by the extending class, it then feeds the data to the analysePacket method, which the extending class should implement. The class should then handle the monitoring for that packet.

Version:
$Id: MonitorSkeleton.java,v 1.19 2004/08/01 10:40:41 tdb Exp $
Author:
$Author: tdb $

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
protected  Queue _alerterQueue
          A reference to the Alerter queue, into which all new alerts will be placed.
private  ConfigurationProxy _cp
          A reference to the configuration proxy in use
protected  Logger _logger
          This holds a reference to the system logger that is being used.
protected  int _qID
          The ID of the queue the monitor will use.
protected  boolean _running
          The state of the alerter thread
 String REVISION
          The current CVS revision of this class
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
MonitorSkeleton()
          Constructs and start the monitor reading its data
 
Method Summary
protected abstract  void analysePacket(XMLPacket packet)
          Extending classes should override this method to analyse the given packet for the attribute they are responsible for.
protected  boolean checkBooleanConfig(String source, String name)
          Checks a boolean configuration variable.
private  void fireAlert(Register reg, int lastAlert, String source, String currentValue, String attributeName)
          Fires an alert.
abstract  String getDescription()
          Return the String representation of what the alerter does
protected abstract  Queue getQueue()
          Obtain the queue which contains the data the Monitor is reading.
protected  int getQueueId()
          Create a queue ID on the feeding data queue
protected  void processAlert(int newThreshold, String attributeName, Register reg, String source, String currentValue)
          Once a Monitor has determined which threshold the given data packet is at, it should then call this method.
 void run()
          Obtains data from the monitors data queue and passes the packet to the analysePacket method.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REVISION

public final String REVISION
The current CVS revision of this class

See Also:
Constant Field Values

_logger

protected Logger _logger
This holds a reference to the system logger that is being used.


_alerterQueue

protected Queue _alerterQueue
A reference to the Alerter queue, into which all new alerts will be placed.


_cp

private ConfigurationProxy _cp
A reference to the configuration proxy in use


_qID

protected int _qID
The ID of the queue the monitor will use. Initially -1, but initialised on first use.


_running

protected boolean _running
The state of the alerter thread

Constructor Detail

MonitorSkeleton

public MonitorSkeleton()
Constructs and start the monitor reading its data

Method Detail

run

public void run()
Obtains data from the monitors data queue and passes the packet to the analysePacket method.

Specified by:
run in interface Runnable
Overrides:
run in class Thread

analysePacket

protected abstract void analysePacket(XMLPacket packet)
Extending classes should override this method to analyse the given packet for the attribute they are responsible for.


processAlert

protected void processAlert(int newThreshold,
                            String attributeName,
                            Register reg,
                            String source,
                            String currentValue)
Once a Monitor has determined which threshold the given data packet is at, it should then call this method. This method handles ALL the alerting logic to determine escalation of alerts. If it decides an alert needs to be send, it will send one using fireAlert.

Parameters:
newThreshold - the threshold that has been determined by the monitor
attributeName - the textual name of the attribute the monitor is responsible for
reg - the register that holds the current alert state for the machine/attribute
source - the source of the alert eg, hostname
currentValue - the data value for the attribute

getDescription

public abstract String getDescription()
Return the String representation of what the alerter does

Specified by:
getDescription in interface PluginMonitor
Returns:
the description

checkBooleanConfig

protected boolean checkBooleanConfig(String source,
                                     String name)
Checks a boolean configuration variable.

Parameters:
source - the configuration to look up
name - the key to look up

fireAlert

private void fireAlert(Register reg,
                       int lastAlert,
                       String source,
                       String currentValue,
                       String attributeName)
Fires an alert. This creates a new Alert object and populates it with the given alert information. It then adds the alert to the Alerter queue. This method should only be called by the processAlert method.

Parameters:
reg - the register holding the state values for the alert
source - the source of the alert eg, hostname
currentValue - the data value for the attribute
attributeName - the textual name of the attribute the alert is for

getQueue

protected abstract Queue getQueue()
Obtain the queue which contains the data the Monitor is reading. eg, MonitorManager.getInstance().getDataQueue()


getQueueId

protected int getQueueId()
Create a queue ID on the feeding data queue



Copyright © 2000-2003 i-scream. All Rights Reserved.