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.12 by tdb, Wed May 23 18:29:36 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 57 | Line 68 | public class Queue__Monitor extends MonitorSkeleton {
68                  String dataKey = (String) i.next();
69                  if(dataKey.startsWith("packet.queue.attributes.queue")) {
70                      String queueSize = packet.getParam(dataKey);
71 +                    
72 +                    // silently ignore these
73 +                    // they're generated by the queueMonitor for deleted queues
74 +                    if(queueSize.equals("[deleted]")) {
75 +                        break;
76 +                    }
77  
78                      // *** now process this queue ***
79  
80                      // check if we've seen this queue before on a previous run
81                      // if not, we need to create a register for it
82                      if(!queueRegisters.containsKey(dataKey)) {
83 <                        queueRegisters.put(dataKey, new Register(source, _name));
83 >                        queueRegisters.put(dataKey, new Register(_name, _name));
84                      }
85  
86                      // get the register for this disk
# Line 86 | Line 103 | public class Queue__Monitor extends MonitorSkeleton {
103                      
104                      boolean useValue = false;
105                      try {
106 <                        String option = _cp.getProperty("Host." + source, "Monitor." + _name + ".thresholdMeasure");
106 >                        String option = _cp.getProperty(_name, "Monitor." + _name + ".thresholdMeasure");
107                          if (option.equals("VALUE")) {
108                              useValue = true;
109                          }                            
# Line 94 | Line 111 | public class Queue__Monitor extends MonitorSkeleton {
111                          // we default to percentage
112                      }
113                      
114 <                    // this  bit determines if the disk check is a % check
115 <                    // or a kb check
114 >                    // this  bit determines if the queue check is a % check
115 >                    // or a literal value check
116                      double checkValue;
117                      String type;
118                      if(useValue) {
119 <                        // kb disk in use
119 >                        // queue count
120                          checkValue = qSize;
121                          type = "count";
122                      } else {
123 <                        // % disk in use
123 >                        // % of queue
124                          checkValue = (qSize / qMax) * 100;
125                          type = "%";
126                      }
127                      
111                    
112                    
128                      int newThreshold = checkAttributeThreshold(checkValue, reg);
129          
130                      // format the checkValue to a String
# Line 119 | Line 134 | public class Queue__Monitor extends MonitorSkeleton {
134                      String strCheckValue = nf.format(checkValue);
135  
136                      // say which disk had the problem
137 <                    String attributeName = "Size of queue " + type + " in " + queueName;
137 >                    String attributeName = "Size of queue " + type + " in " + queueName + " " + dataKey.substring(dataKey.lastIndexOf('.')+1);
138                                              
139 <                    processAlert(newThreshold, attributeName, reg, source, strCheckValue);
139 >                    processAlert(newThreshold, attributeName, reg, SOURCE, strCheckValue);
140                    
141                  }
142              }
# Line 152 | Line 167 | public class Queue__Monitor extends MonitorSkeleton {
167      }
168  
169   //---PRIVATE METHODS---
170 <
170 >    
171 >    /**
172 >     * Checks a piece of current data, and returns the
173 >     * threshold it breaches, if any.
174 >     *
175 >     * @param qSize the size of a queue
176 >     * @param reg the Register for the host
177 >     * @return the threshold level breached, if any
178 >     */
179      private int checkAttributeThreshold(double qSize, Register reg) {
180          for(int thresholdLevel = Alert.thresholdLevels.length - 1; thresholdLevel >= 0; thresholdLevel--) {
181              if (reg.getThreshold(thresholdLevel) != -1.0) {
# Line 165 | Line 188 | public class Queue__Monitor extends MonitorSkeleton {
188      }
189  
190   //---ACCESSOR/MUTATOR METHODS---
191 +    
192 +    /**
193 +     * Returns a reference to a specific Queue for this
194 +     * monitor. This Queue returns only the data packets
195 +     * (based on type) that we want too look at.
196 +     *
197 +     * @return a reference to a Queue
198 +     */
199 +    protected Queue getQueue() {
200 +        return MonitorManager.getInstance().getOtherQueue();
201 +    }
202  
203 +
204   //---ATTRIBUTES---
205  
206      /**
# Line 183 | Line 218 | public class Queue__Monitor extends MonitorSkeleton {
218       * A reference to the configuration proxy in use
219       */
220      private ConfigurationProxy _cp = ConfigurationProxy.getInstance();
221 <
221 >    
222 >    /**
223 >     * A HashMap of Registers (or groups of Registers), one
224 >     * for each host we're monitoring.
225 >     */
226      private HashMap _hosts = new HashMap();
227  
228   //---STATIC ATTRIBUTES---

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines