55 |
|
// key prefix |
56 |
|
String keyPrefix = "packet.disk.p"; |
57 |
|
|
58 |
< |
// a tempory holder for all the disk attributes we find |
58 |
> |
// a temporary holder for all the disk attributes we find |
59 |
|
ArrayList disks = new ArrayList(); |
60 |
|
|
61 |
|
// unfortunatly we need to check the whole packet |
99 |
|
|
100 |
|
// check if we've seen this disk before on a previous run |
101 |
|
// if not, we need to create a register for it |
102 |
< |
if(!diskRegisters.containsKey(diskNumber)) { |
103 |
< |
diskRegisters.put(diskNumber, new Register(source, _name, mount)); |
102 |
> |
// nb. use the mount as the key as this is unlikely to change, |
103 |
> |
// unlike diskNumber which could easily change |
104 |
> |
// (diskNumber is based on the order of df's output!) |
105 |
> |
if(!diskRegisters.containsKey(mount)) { |
106 |
> |
diskRegisters.put(mount, new Register(source, _name, mount)); |
107 |
|
} |
108 |
|
|
109 |
|
// get the register for this disk |
110 |
< |
Register reg = (Register) diskRegisters.get(diskNumber); |
110 |
> |
Register reg = (Register) diskRegisters.get(mount); |
111 |
|
|
112 |
|
// get the packet data |
113 |
|
double diskTotal, diskAvail; |
126 |
|
|
127 |
|
boolean useValue = false; |
128 |
|
try { |
129 |
< |
String option = _cp.getProperty("Host." + source, "Monitor." + _name + ".thresholdMeasure"); |
129 |
> |
// try looking for a mount-point specific thresholdMeasure first |
130 |
> |
String option = _cp.getProperty("Host." + source, "Monitor." + _name + "." + mount + ".thresholdMeasure"); |
131 |
|
if (option.equals("VALUE")) { |
132 |
|
useValue = true; |
133 |
< |
} |
133 |
> |
} |
134 |
|
} catch (PropertyNotFoundException e) { |
135 |
< |
// we default to percentage |
135 |
> |
try { |
136 |
> |
// now look for a more general thresholdMeasure |
137 |
> |
String option = _cp.getProperty("Host." + source, "Monitor." + _name + ".thresholdMeasure"); |
138 |
> |
if (option.equals("VALUE")) { |
139 |
> |
useValue = true; |
140 |
> |
} |
141 |
> |
} catch (PropertyNotFoundException f) { |
142 |
> |
// we default to percentage in any case |
143 |
> |
} |
144 |
|
} |
145 |
|
|
146 |
|
// this bit determines if the disk check is a % check |
216 |
|
* @param negateCheck whether to negate the check |
217 |
|
* @return the threshold level breached, if any |
218 |
|
*/ |
219 |
< |
private int checkAttributeThreshold(double diskInUse, Register reg, boolean negateCheck) { |
219 |
> |
private int checkAttributeThreshold(double value, Register reg, boolean negateCheck) { |
220 |
|
for(int thresholdLevel = Alert.thresholdLevels.length - 1; thresholdLevel >= 0; thresholdLevel--) { |
221 |
|
if (reg.getThreshold(thresholdLevel) != -1.0) { |
222 |
|
if(!negateCheck) { |
223 |
|
// normal check - has the value gone *over* the threshold |
224 |
< |
if(((double) reg.getThreshold(thresholdLevel)) < diskInUse) { |
224 |
> |
if(((double) reg.getThreshold(thresholdLevel)) < value) { |
225 |
|
return thresholdLevel; |
226 |
|
} |
227 |
|
} |
228 |
|
else { |
229 |
|
// negated check - has the value gone *under* the threshold |
230 |
< |
if(((double) reg.getThreshold(thresholdLevel)) > diskInUse) { |
230 |
> |
if(((double) reg.getThreshold(thresholdLevel)) > value) { |
231 |
|
return thresholdLevel; |
232 |
|
} |
233 |
|
} |