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.4 by ajm, Thu Mar 22 17:57:06 2001 UTC vs.
Revision 1.14 by tdb, Sat May 18 18:16:00 2002 UTC

# Line 1 | Line 1
1 + /*
2 + * i-scream central monitoring system
3 + * Copyright (C) 2000-2002 i-scream
4 + *
5 + * This program is free software; you can redistribute it and/or
6 + * modify it under the terms of the GNU General Public License
7 + * as published by the Free Software Foundation; either version 2
8 + * of the License, or (at your option) any later version.
9 + *
10 + * This program is distributed in the hope that it will be useful,
11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 + * GNU General Public License for more details.
14 + *
15 + * You should have received a copy of the GNU General Public License
16 + * along with this program; if not, write to the Free Software
17 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 + */
19 +
20   //---PACKAGE DECLARATION---
21 < package uk.org.iscream.client.monitors;
21 > package uk.org.iscream.cms.server.client.monitors;
22  
23   //---IMPORTS---
24   import java.util.HashMap;
# Line 7 | Line 26 | import java.util.ArrayList;
26   import java.util.Set;
27   import java.util.Iterator;
28   import java.text.NumberFormat;
29 < import uk.org.iscream.client.*;
30 < import uk.org.iscream.core.*;
31 < import uk.org.iscream.util.*;
32 < import uk.org.iscream.componentmanager.*;
29 > import uk.org.iscream.cms.server.client.*;
30 > import uk.org.iscream.cms.server.core.*;
31 > import uk.org.iscream.cms.server.util.*;
32 > import uk.org.iscream.cms.server.componentmanager.*;
33  
34   /**
35   * This Monitor watches the internal server queues.
# Line 28 | Line 47 | public class Queue__Monitor extends MonitorSkeleton {
47       */
48      public final String REVISION = "$Revision$";
49      
50 +    /**
51 +     * A description of this monitor
52 +     */
53      public final String DESC = "Who watches the watchmen?";
54      
55 +    private final String SOURCE = "i-scream-server";
56 +    
57   //---STATIC METHODS---
58  
59   //---CONSTRUCTORS---
60  
61   //---PUBLIC METHODS---
62 <
62 >    
63 >    /**
64 >     * Analyse a packet of data, and generate an alert if
65 >     * necessary.
66 >     *
67 >     * @param packet the XMLPacket to analyse
68 >     */
69      public void analysePacket(XMLPacket packet) {
70          if (packet.getParam("packet.attributes.type").equals("queueStat")) {
71              String source = packet.getParam("packet.attributes.hashCode");
# Line 57 | Line 87 | public class Queue__Monitor extends MonitorSkeleton {
87                  String dataKey = (String) i.next();
88                  if(dataKey.startsWith("packet.queue.attributes.queue")) {
89                      String queueSize = packet.getParam(dataKey);
90 +                    
91 +                    // silently ignore these
92 +                    // they're generated by the queueMonitor for deleted queues
93 +                    if(queueSize.equals("[deleted]")) {
94 +                        break;
95 +                    }
96  
97                      // *** now process this queue ***
98  
99                      // check if we've seen this queue before on a previous run
100                      // if not, we need to create a register for it
101                      if(!queueRegisters.containsKey(dataKey)) {
102 <                        queueRegisters.put(dataKey, new Register(source, _name));
102 >                        queueRegisters.put(dataKey, new Register(_name, _name));
103                      }
104  
105                      // get the register for this disk
# Line 86 | Line 122 | public class Queue__Monitor extends MonitorSkeleton {
122                      
123                      boolean useValue = false;
124                      try {
125 <                        String option = _cp.getProperty("Host." + source, "Monitor." + _name + ".thresholdMeasure");
125 >                        String option = _cp.getProperty(_name, "Monitor." + _name + ".thresholdMeasure");
126                          if (option.equals("VALUE")) {
127                              useValue = true;
128                          }                            
# Line 94 | Line 130 | public class Queue__Monitor extends MonitorSkeleton {
130                          // we default to percentage
131                      }
132                      
133 <                    // this  bit determines if the disk check is a % check
134 <                    // or a kb check
133 >                    // this  bit determines if the queue check is a % check
134 >                    // or a literal value check
135                      double checkValue;
136                      String type;
137                      if(useValue) {
138 <                        // kb disk in use
138 >                        // queue count
139                          checkValue = qSize;
140                          type = "count";
141                      } else {
142 <                        // % disk in use
142 >                        // % of queue
143                          checkValue = (qSize / qMax) * 100;
144                          type = "%";
145                      }
# Line 117 | Line 153 | public class Queue__Monitor extends MonitorSkeleton {
153                      String strCheckValue = nf.format(checkValue);
154  
155                      // say which disk had the problem
156 <                    String attributeName = "Size of queue " + type + " in " + queueName;
156 >                    String attributeName = "Size of queue " + type + " in " + queueName + " " + dataKey.substring(dataKey.lastIndexOf('.')+1);
157                                              
158 <                    processAlert(newThreshold, attributeName, reg, source, strCheckValue);
158 >                    processAlert(newThreshold, attributeName, reg, SOURCE, strCheckValue);
159                    
160                  }
161              }
# Line 130 | Line 166 | public class Queue__Monitor extends MonitorSkeleton {
166       * Overrides the {@link java.lang.Object#toString() Object.toString()}
167       * method to provide clean logging (every class should have this).
168       *
169 <     * This uses the uk.org.iscream.util.NameFormat class
169 >     * This uses the uk.org.iscream.cms.server.util.NameFormat class
170       * to format the toString()
171       *
172       * @return the name of this class and its CVS revision
# Line 150 | Line 186 | public class Queue__Monitor extends MonitorSkeleton {
186      }
187  
188   //---PRIVATE METHODS---
189 <
189 >    
190 >    /**
191 >     * Checks a piece of current data, and returns the
192 >     * threshold it breaches, if any.
193 >     *
194 >     * @param qSize the size of a queue
195 >     * @param reg the Register for the host
196 >     * @return the threshold level breached, if any
197 >     */
198      private int checkAttributeThreshold(double qSize, Register reg) {
199          for(int thresholdLevel = Alert.thresholdLevels.length - 1; thresholdLevel >= 0; thresholdLevel--) {
200              if (reg.getThreshold(thresholdLevel) != -1.0) {
# Line 163 | Line 207 | public class Queue__Monitor extends MonitorSkeleton {
207      }
208  
209   //---ACCESSOR/MUTATOR METHODS---
210 <
210 >    
211 >    /**
212 >     * Returns a reference to a specific Queue for this
213 >     * monitor. This Queue returns only the data packets
214 >     * (based on type) that we want too look at.
215 >     *
216 >     * @return a reference to a Queue
217 >     */
218      protected Queue getQueue() {
219          return MonitorManager.getInstance().getOtherQueue();
220      }
# Line 186 | Line 237 | public class Queue__Monitor extends MonitorSkeleton {
237       * A reference to the configuration proxy in use
238       */
239      private ConfigurationProxy _cp = ConfigurationProxy.getInstance();
240 <
240 >    
241 >    /**
242 >     * A HashMap of Registers (or groups of Registers), one
243 >     * for each host we're monitoring.
244 >     */
245      private HashMap _hosts = new HashMap();
246  
247   //---STATIC ATTRIBUTES---

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines