ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/client/monitors/Load__Monitor.java
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/client/monitors/Load__Monitor.java (file contents):
Revision 1.2 by ajm, Thu Mar 22 17:57:06 2001 UTC vs.
Revision 1.3 by tdb, Fri Mar 23 02:32:49 2001 UTC

# Line 23 | Line 23 | public class Load__Monitor extends MonitorSkeleton {
23       */
24      public final String REVISION = "$Revision$";
25      
26 +    /**
27 +     * A description of this monitor
28 +     */
29      public final String DESC = "Monitors Load.";
30      
31   //---STATIC METHODS---
# Line 30 | Line 33 | public class Load__Monitor extends MonitorSkeleton {
33   //---CONSTRUCTORS---
34  
35   //---PUBLIC METHODS---
36 <
36 >    
37 >    /**
38 >     * Analyse a packet of data, and generate an alert if
39 >     * necessary.
40 >     *
41 >     * @param packet the XMLPacket to analyse
42 >     */
43      public void analysePacket(XMLPacket packet) {
44  
45          String source = packet.getParam("packet.attributes.machine_name");
# Line 47 | Line 56 | public class Load__Monitor extends MonitorSkeleton {
56              String attribute = _attributes[attributeNum];
57              String attributeName = _attributeNames[attributeNum];
58              String currentValue = packet.getParam(attribute);
59 +            // find out our new threshold
60              int newThreshold = checkAttributeThreshold(currentValue, reg);
61 +            // process this data to generate an alert
62              processAlert(newThreshold, attributeName, reg, source, currentValue);
63          }
64  
# Line 77 | Line 88 | public class Load__Monitor extends MonitorSkeleton {
88      }
89  
90   //---PRIVATE METHODS---
91 <
91 >    
92 >    /**
93 >     * Checks a piece of current data, and returns the
94 >     * threshold it breaches, if any.
95 >     *
96 >     * @param attributeString a String representing the current data value
97 >     * @param reg the Register for the host
98 >     * @return the threshold level breached, if any
99 >     */
100      private int checkAttributeThreshold(String attributeString, Register reg) {
101          for(int thresholdLevel = Alert.thresholdLevels.length - 1; thresholdLevel >= 0; thresholdLevel--) {
102              if (reg.getThreshold(thresholdLevel) != -1.0) {
# Line 94 | Line 113 | public class Load__Monitor extends MonitorSkeleton {
113          }
114          return Alert.thresholdNORMAL;
115      }
116 <
116 >    
117 >    /**
118 >     * Initialises a HashMap of Registers with the current list
119 >     * of attributes. This is only used if we are looking at more
120 >     * than one distinct attribute.
121 >     *
122 >     * @param source the host we are looking at
123 >     * @param attributeRegisters a HashMap to put the new Registers in
124 >     */
125      private void initAttributeRegsiters(String source, HashMap attributeRegisters) {
126          for(int attributeNum = 0; attributeNum < _attributes.length; attributeNum++) {
127              String attributeName = _attributes[attributeNum].substring(_attributes[attributeNum].lastIndexOf(".") + 1);
# Line 103 | Line 130 | public class Load__Monitor extends MonitorSkeleton {
130      }
131  
132   //---ACCESSOR/MUTATOR METHODS---
133 <
133 >    
134 >    /**
135 >     * Returns a reference to a specific Queue for this
136 >     * monitor. This Queue returns only the data packets
137 >     * (based on type) that we want too look at.
138 >     *
139 >     * @return a reference to a Queue
140 >     */
141      protected Queue getQueue() {
142          return MonitorManager.getInstance().getDataQueue();
143      }
# Line 123 | Line 157 | public class Load__Monitor extends MonitorSkeleton {
157      private String _name = "Load";
158      
159      /**
160 <     * A reference to the configuration proxy in use
160 >     * A HashMap of Registers (or groups of Registers), one
161 >     * for each host we're monitoring.
162       */
128    private ConfigurationProxy _cp = ConfigurationProxy.getInstance();
129
163      private HashMap _hosts = new HashMap();
164 <
164 >    
165 >    /**
166 >     * An array of attributes which we will be checking.
167 >     */
168      private String[] _attributes = { "packet.load.load1", "packet.load.load5", "packet.load.load15" };
169 +    
170 +    /**
171 +     * An array of "nice names" for the attributes in _attributes.
172 +     */
173      private String[] _attributeNames = {"1 min load avg.", "5 min load avg.", "15 min load avg."};
174  
175   //---STATIC ATTRIBUTES---

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines