27 |
|
*/ |
28 |
|
public final String REVISION = "$Revision$"; |
29 |
|
|
30 |
+ |
/** |
31 |
+ |
* A description of this monitor |
32 |
+ |
*/ |
33 |
|
public final String DESC = "Monitors all host disks."; |
34 |
|
|
35 |
|
//---STATIC METHODS--- |
37 |
|
//---CONSTRUCTORS--- |
38 |
|
|
39 |
|
//---PUBLIC METHODS--- |
40 |
< |
|
40 |
> |
|
41 |
> |
/** |
42 |
> |
* Analyse a packet of data, and generate an alert if |
43 |
> |
* necessary. |
44 |
> |
* |
45 |
> |
* @param packet the XMLPacket to analyse |
46 |
> |
*/ |
47 |
|
public void analysePacket(XMLPacket packet) { |
48 |
|
String source = packet.getParam("packet.attributes.machine_name"); |
49 |
|
if (!_hosts.containsKey(source)) { |
51 |
|
} |
52 |
|
|
53 |
|
HashMap diskRegisters = (HashMap) _hosts.get(source); |
54 |
< |
|
54 |
> |
|
55 |
> |
// key prefix |
56 |
> |
String keyPrefix = "packet.disk.p"; |
57 |
> |
|
58 |
|
// a tempory holder for all the disk attributes we find |
59 |
|
ArrayList disks = new ArrayList(); |
60 |
|
|
64 |
|
Iterator i = packetSet.iterator(); |
65 |
|
while (i.hasNext()) { |
66 |
|
String dataKey = (String) i.next(); |
67 |
< |
if(dataKey.startsWith("packet.disk.p")) { |
67 |
> |
if(dataKey.startsWith(keyPrefix)) { |
68 |
|
if(!disks.contains(dataKey)) { |
69 |
|
String diskNumber = ""; |
70 |
|
|
71 |
|
// pos is after "packet.disk.p" |
72 |
< |
int pos = 13; |
72 |
> |
int pos = keyPrefix.length(); |
73 |
|
while (dataKey.charAt(pos) != '.') { |
74 |
|
diskNumber = diskNumber + dataKey.charAt(pos); |
75 |
|
pos++; |
78 |
|
// add the disk to our list, with the packet data |
79 |
|
|
80 |
|
// used (we won't use this value - but we need it to forget about it ;) |
81 |
< |
disks.add("packet.disk.p" + diskNumber + ".attributes.used"); |
81 |
> |
disks.add(keyPrefix + diskNumber + ".attributes.used"); |
82 |
|
|
83 |
|
// device |
84 |
< |
disks.add("packet.disk.p" + diskNumber + ".attributes.name"); |
85 |
< |
String device = packet.getParam("packet.disk.p" + diskNumber + ".attributes.name"); |
84 |
> |
disks.add(keyPrefix + diskNumber + ".attributes.name"); |
85 |
> |
String device = packet.getParam(keyPrefix + diskNumber + ".attributes.name"); |
86 |
|
// mount point |
87 |
< |
disks.add("packet.disk.p" + diskNumber + ".attributes.mount"); |
88 |
< |
String mount = packet.getParam("packet.disk.p" + diskNumber + ".attributes.mount"); |
87 |
> |
disks.add(keyPrefix + diskNumber + ".attributes.mount"); |
88 |
> |
String mount = packet.getParam(keyPrefix + diskNumber + ".attributes.mount"); |
89 |
|
|
90 |
|
// these next two will be used to calculate the %age |
91 |
|
// total |
92 |
< |
disks.add("packet.disk.p" + diskNumber + ".attributes.kbytes"); |
93 |
< |
String total = packet.getParam("packet.disk.p" + diskNumber + ".attributes.kbytes"); |
92 |
> |
disks.add(keyPrefix + diskNumber + ".attributes.kbytes"); |
93 |
> |
String total = packet.getParam(keyPrefix + diskNumber + ".attributes.kbytes"); |
94 |
|
// available |
95 |
< |
disks.add("packet.disk.p" + diskNumber + ".attributes.avail"); |
96 |
< |
String avail = packet.getParam("packet.disk.p" + diskNumber + ".attributes.avail"); |
95 |
> |
disks.add(keyPrefix + diskNumber + ".attributes.avail"); |
96 |
> |
String avail = packet.getParam(keyPrefix + diskNumber + ".attributes.avail"); |
97 |
|
|
98 |
|
// *** now process this disk *** |
99 |
|
|
188 |
|
} |
189 |
|
|
190 |
|
//---PRIVATE METHODS--- |
191 |
< |
|
191 |
> |
|
192 |
> |
/** |
193 |
> |
* Checks a piece of current data, and returns the |
194 |
> |
* threshold it breaches, if any. |
195 |
> |
* |
196 |
> |
* @param diskInUse the amount of space in use |
197 |
> |
* @param reg the Register for the host |
198 |
> |
* @return the threshold level breached, if any |
199 |
> |
*/ |
200 |
|
private int checkAttributeThreshold(double diskInUse, Register reg) { |
201 |
|
for(int thresholdLevel = Alert.thresholdLevels.length - 1; thresholdLevel >= 0; thresholdLevel--) { |
202 |
|
if (reg.getThreshold(thresholdLevel) != -1.0) { |
210 |
|
|
211 |
|
//---ACCESSOR/MUTATOR METHODS--- |
212 |
|
|
213 |
+ |
/** |
214 |
+ |
* Returns a reference to a specific Queue for this |
215 |
+ |
* monitor. This Queue returns only the data packets |
216 |
+ |
* (based on type) that we want too look at. |
217 |
+ |
* |
218 |
+ |
* @return a reference to a Queue |
219 |
+ |
*/ |
220 |
|
protected Queue getQueue() { |
221 |
|
return MonitorManager.getInstance().getDataQueue(); |
222 |
|
} |
238 |
|
* A reference to the configuration proxy in use |
239 |
|
*/ |
240 |
|
private ConfigurationProxy _cp = ConfigurationProxy.getInstance(); |
241 |
< |
|
241 |
> |
|
242 |
> |
/** |
243 |
> |
* A HashMap of Registers (or groups of Registers), one |
244 |
> |
* for each host we're monitoring. |
245 |
> |
*/ |
246 |
|
private HashMap _hosts = new HashMap(); |
247 |
|
|
248 |
|
//---STATIC ATTRIBUTES--- |