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

java.lang.Object
  extended byuk.org.iscream.cms.server.client.Register

public class Register
extends Object

The Register class holds theshold values, the last level of alert for each attribute for a monitor and the time of last alert sent for each alert level. This class is used by monitor classes so they can determine how often they should send alerts when breaching alert levels. It also stores (and keeps uptodate (via the configuration proxy) the threshold values for the monitor.

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

Field Summary
private  String _attributeName
          The attribute name, as obtained from the configuration.
private  ConfigurationProxy _cp
          A reference to the configuration proxy in use
private  String _hostname
          The host this register is for
private  long _initialAlertTime
          Initial times that an alert was first raised.
private  int _lastAlertLevel
          An array of last alert levels for each attribute this register is looking after.
private  long _lastAlertTimeout
          An array of last alert timeout levels for each attribute this register is looking after.
private  int _lastThresholdLevel
          An array of last threshold levels for each attribute this register is looking after.
private  int _maxLevelCount
          The number of times the maximum level alert has occured IN A ROW, this is escalated by the escalate(int) method, and reset by the setLastAlertLevel(int, int) method
private  String _monitorName
          The monitor this register is for
private  long[] _times
          An array of arrays containing time an alert of each level was last sent for each attribute.
static String REVISION
          The current CVS revision of this class
 
Constructor Summary
Register(String hostname, String monitorName)
          Construct a Register with the hostname and monitorName (for obtaining the threshold values).
Register(String hostname, String monitorName, String attributeName)
          Construct a Register with the hostname and monitorName (for obtaining the threshold values).
 
Method Summary
 void escalateAlert()
          Advances the alert level to the next one up.
 long getAlertTimeout(int level)
          Gets the alert timeout value for the given level of alert.
 long getInitialAlertTime()
          Returns the time that the first alert was sent for an attribute that has passed a threshold value
 int getLastAlertLevel()
          Gets the last alert level
 long getLastAlertTimeout()
          Gets the timeout value of the last alert sent
 int getLastThresholdLevel()
          Gets the last threshold level
 int getNextAlertLevel()
          Either advances to the next alert level, or if the maximum alert level has been reached, simply returns that.
 double getThreshold(int level)
          Gets the threshold value for the given level of alert.
private  String getThresholdConfig(int level, String attributeName)
          Obtains a threshold value from the configuration for a given level.
 long getTimeLastSent()
          Gets the time an alert was sent at the given level.
 void setLastAlertLevel(int level)
          Sets the last alert level Note that if this is setting to an OK level alert, it resets _maxLevelCount.
 void setLastAlertTimeout(long timeout)
          Sets the timeout value of the last alert sent
 void setLastThresholdLevel(int level)
          Sets the last threshold level
 void setTimeLastSent(long value)
          Gets the time an alert was sent at the given level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
The current CVS revision of this class

See Also:
Constant Field Values

_hostname

private String _hostname
The host this register is for


_monitorName

private String _monitorName
The monitor this register is for


_attributeName

private String _attributeName
The attribute name, as obtained from the configuration. eg, idle or /var


_lastAlertLevel

private int _lastAlertLevel
An array of last alert levels for each attribute this register is looking after.


_lastThresholdLevel

private int _lastThresholdLevel
An array of last threshold levels for each attribute this register is looking after.


_lastAlertTimeout

private long _lastAlertTimeout
An array of last alert timeout levels for each attribute this register is looking after.


_times

private long[] _times
An array of arrays containing time an alert of each level was last sent for each attribute.


_initialAlertTime

private long _initialAlertTime
Initial times that an alert was first raised.


_cp

private ConfigurationProxy _cp
A reference to the configuration proxy in use


_maxLevelCount

private int _maxLevelCount
The number of times the maximum level alert has occured IN A ROW, this is escalated by the escalate(int) method, and reset by the setLastAlertLevel(int, int) method

Constructor Detail

Register

public Register(String hostname,
                String monitorName)
Construct a Register with the hostname and monitorName (for obtaining the threshold values). This constructs a generic register for a specific monitor.

Parameters:
hostname - the hostname this register is for
monitorName - the monitor this register is for

Register

public Register(String hostname,
                String monitorName,
                String attributeName)
Construct a Register with the hostname and monitorName (for obtaining the threshold values). This constructs a register for a specific attribute check by a monitor.

Parameters:
hostname - the hostname this register is for
monitorName - the monitor this register is for
attributeName - the specific attribute this register is for
Method Detail

escalateAlert

public void escalateAlert()
Advances the alert level to the next one up. This keeps track of the number of the number of times the highest NON-FINAL alert level has been reached. Note this isn't a specific level, just the highest, so you could configure more levels and not affect this. If the count exceeds the number of times set in the configuration, it escalates to a FINAL alert if we're using FINAL's. It determines if to use FINAL's from the config entry reachFINALcount, when the count exceeds this value, it escalates to a FINAL. If that attribute is mis-read or is not configured. It will NEVER reach a FINAL.


getThresholdConfig

private String getThresholdConfig(int level,
                                  String attributeName)
                           throws PropertyNotFoundException
Obtains a threshold value from the configuration for a given level. The attribute name specifies which property to get. eg, attributeName = idle it will look for Monitor..idle.threshold. eg, attributeName = null Monitor..threshold. Note that if its null, this will get the threshold for the monitor as a whole, not the specific attribute.

Parameters:
level - the alert level to get the attribute for
attributeName - the attribute to get the threshold for
Returns:
the threshold obtained
Throws:
PropertyNotFoundException

getLastAlertLevel

public int getLastAlertLevel()
Gets the last alert level

Returns:
the last alert level

setLastThresholdLevel

public void setLastThresholdLevel(int level)
Sets the last threshold level

Parameters:
level - the new last threshold level

getLastThresholdLevel

public int getLastThresholdLevel()
Gets the last threshold level

Returns:
the last threshold level

setLastAlertLevel

public void setLastAlertLevel(int level)
Sets the last alert level Note that if this is setting to an OK level alert, it resets _maxLevelCount. This also sets the "initialAlertTime" if the next alert after OK is set. And resets it to 0 if it IS an OK.

Parameters:
level - the new last alert level

getTimeLastSent

public long getTimeLastSent()
Gets the time an alert was sent at the given level.

Returns:
the time last sent

setTimeLastSent

public void setTimeLastSent(long value)
Gets the time an alert was sent at the given level.

Parameters:
value - the new time

getThreshold

public double getThreshold(int level)
Gets the threshold value for the given level of alert. If there is no alert threshold for a given level, this returns -1.0

Parameters:
level - the alert level

getAlertTimeout

public long getAlertTimeout(int level)
Gets the alert timeout value for the given level of alert. This value is in millis, and is converted from the value in the config, which should be seconds. Note that if the alert timeout for the current monitor is not configured, it will try to obtain the default timeout for all Monitor's. If there is no alert timeout for either the monitor or a default setting this returns 0. Note that this is dependant on the threshold value given, the timeout is obatined from the config, then divided by the threshold value, this allows alerts to progress faster should a higher threshold value be passed

Parameters:
level - the alert level

getNextAlertLevel

public int getNextAlertLevel()
Either advances to the next alert level, or if the maximum alert level has been reached, simply returns that. Note this method will NEVER reach the last alert level in the list, this is assumed to be FINAL, and special logic is in place to handle that.


getLastAlertTimeout

public long getLastAlertTimeout()
Gets the timeout value of the last alert sent

Returns:
the last timeout value

setLastAlertTimeout

public void setLastAlertTimeout(long timeout)
Sets the timeout value of the last alert sent

Parameters:
timeout - the new value

getInitialAlertTime

public long getInitialAlertTime()
Returns the time that the first alert was sent for an attribute that has passed a threshold value



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