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/Queue__Monitor.java
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/client/monitors/Queue__Monitor.java (file contents):
Revision 1.2 by ajm, Thu Mar 22 01:55:18 2001 UTC vs.
Revision 1.8 by tdb, Fri Mar 23 02:32:49 2001 UTC

# Line 28 | Line 28 | public class Queue__Monitor extends MonitorSkeleton {
28       */
29      public final String REVISION = "$Revision$";
30      
31 +    /**
32 +     * A description of this monitor
33 +     */
34      public final String DESC = "Who watches the watchmen?";
35      
36 +    private final String SOURCE = "i-scream-server";
37 +    
38   //---STATIC METHODS---
39  
40   //---CONSTRUCTORS---
41  
42   //---PUBLIC METHODS---
43 <
43 >    
44 >    /**
45 >     * Analyse a packet of data, and generate an alert if
46 >     * necessary.
47 >     *
48 >     * @param packet the XMLPacket to analyse
49 >     */
50      public void analysePacket(XMLPacket packet) {
51 <        if (packet.getParam("packet.attributes.type").equals("data")) {
52 <            String source = packet.getParam("packet.attributes.machine_name");
51 >        if (packet.getParam("packet.attributes.type").equals("queueStat")) {
52 >            String source = packet.getParam("packet.attributes.hashCode");
53              if (!_hosts.containsKey(source)) {
54                  _hosts.put(source, new HashMap());
55              }
# Line 99 | Line 110 | public class Queue__Monitor extends MonitorSkeleton {
110                      double checkValue;
111                      String type;
112                      if(useValue) {
113 <                        // kb disk in use
113 >                        // queue count
114                          checkValue = qSize;
115                          type = "count";
116                      } else {
117 <                        // % disk in use
117 >                        // % of queue
118                          checkValue = (qSize / qMax) * 100;
119                          type = "%";
120                      }
121                      
111                    
112                    
122                      int newThreshold = checkAttributeThreshold(checkValue, reg);
123          
124                      // format the checkValue to a String
# Line 119 | Line 128 | public class Queue__Monitor extends MonitorSkeleton {
128                      String strCheckValue = nf.format(checkValue);
129  
130                      // say which disk had the problem
131 <                    String attributeName = "Size of queue " + type + " in " + queueName;
131 >                    String attributeName = "Size of queue " + type + " in " + queueName + " " + dataKey.substring(dataKey.lastIndexOf('.'));
132                                              
133 <                    processAlert(newThreshold, attributeName, reg, source, strCheckValue);
133 >                    processAlert(newThreshold, attributeName, reg, SOURCE, strCheckValue);
134                    
135                  }
136              }
# Line 152 | Line 161 | public class Queue__Monitor extends MonitorSkeleton {
161      }
162  
163   //---PRIVATE METHODS---
164 <
164 >    
165 >    /**
166 >     * Checks a piece of current data, and returns the
167 >     * threshold it breaches, if any.
168 >     *
169 >     * @param qSize the size of a queue
170 >     * @param reg the Register for the host
171 >     * @return the threshold level breached, if any
172 >     */
173      private int checkAttributeThreshold(double qSize, Register reg) {
174          for(int thresholdLevel = Alert.thresholdLevels.length - 1; thresholdLevel >= 0; thresholdLevel--) {
175              if (reg.getThreshold(thresholdLevel) != -1.0) {
# Line 165 | Line 182 | public class Queue__Monitor extends MonitorSkeleton {
182      }
183  
184   //---ACCESSOR/MUTATOR METHODS---
185 +    
186 +    /**
187 +     * Returns a reference to a specific Queue for this
188 +     * monitor. This Queue returns only the data packets
189 +     * (based on type) that we want too look at.
190 +     *
191 +     * @return a reference to a Queue
192 +     */
193 +    protected Queue getQueue() {
194 +        return MonitorManager.getInstance().getOtherQueue();
195 +    }
196  
197 +
198   //---ATTRIBUTES---
199  
200      /**
# Line 183 | Line 212 | public class Queue__Monitor extends MonitorSkeleton {
212       * A reference to the configuration proxy in use
213       */
214      private ConfigurationProxy _cp = ConfigurationProxy.getInstance();
215 <
215 >    
216 >    /**
217 >     * A HashMap of Registers (or groups of Registers), one
218 >     * for each host we're monitoring.
219 >     */
220      private HashMap _hosts = new HashMap();
221  
222   //---STATIC ATTRIBUTES---

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines