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"; |
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("queueStat")) { |
52 |
|
String source = packet.getParam("packet.attributes.hashCode"); |
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 |
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 |
|
} |
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) { |
134 |
|
String strCheckValue = nf.format(checkValue); |
135 |
|
|
136 |
|
// say which disk had the problem |
137 |
< |
String attributeName = "Size of queue " + type + " in " + queueName + " " + dataKey.substring(dataKey.lastIndexOf('.')); |
137 |
> |
String attributeName = "Size of queue " + type + " in " + queueName + " " + dataKey.substring(dataKey.lastIndexOf('.')+1); |
138 |
|
|
139 |
|
processAlert(newThreshold, attributeName, reg, SOURCE, strCheckValue); |
140 |
|
|
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) { |
188 |
|
} |
189 |
|
|
190 |
|
//---ACCESSOR/MUTATOR METHODS--- |
191 |
< |
|
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 |
|
} |
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--- |