63 |
|
*/ |
64 |
|
public void analysePacket(XMLPacket packet) { |
65 |
|
String source = packet.getParam("packet.attributes.machine_name"); |
66 |
+ |
if(!checkBooleanConfig(source, "Monitor." + _name + ".enable")) { |
67 |
+ |
return; |
68 |
+ |
} |
69 |
|
if (!_hosts.containsKey(source)) { |
70 |
|
_hosts.put(source, new Register(source, _name)); |
71 |
|
} |
114 |
|
// we default to false |
115 |
|
} |
116 |
|
|
117 |
< |
// this bit determines if the memory check is a % check |
118 |
< |
// or a kb check |
117 |
> |
// this bit determines if the memory check is a % check |
118 |
> |
// or a byte check |
119 |
|
String type; |
120 |
|
double curValue; |
121 |
|
int newThreshold; |
122 |
|
if(useValue) { |
123 |
< |
// kb memory available |
123 |
> |
// bytes of memory available |
124 |
|
if(useCache) { |
125 |
|
// NOTE: we take cache as being "probably free" for this check |
126 |
|
curValue = memoryFree + memoryCache; |
129 |
|
} |
130 |
|
// negate check |
131 |
|
newThreshold = checkAttributeThreshold(curValue, reg, true); |
132 |
< |
type = "kb"; |
132 |
> |
type = "bytes"; |
133 |
|
} else { |
134 |
|
// % memory in use |
135 |
|
if(useCache) { |
136 |
|
// NOTE: we take cache as being "probably free" for this check |
137 |
< |
curValue = (1 - ((memoryFree + memoryCache) / memoryTotal)) * 100; |
137 |
> |
curValue = (1 - (((double)memoryFree + (double)memoryCache) / (double)memoryTotal)) * 100; |
138 |
|
} else { |
139 |
< |
curValue = (1 - (memoryFree / memoryTotal)) * 100; |
139 |
> |
curValue = (1 - ((double)memoryFree / (double)memoryTotal)) * 100; |
140 |
|
} |
141 |
|
// normal check |
142 |
|
newThreshold = checkAttributeThreshold(curValue, reg, false); |
143 |
|
type = "%"; |
144 |
|
} |
145 |
|
|
146 |
< |
// format the memoryInUse to a String |
146 |
> |
// format the value to a String |
147 |
|
NumberFormat nf = NumberFormat.getInstance(); |
148 |
|
nf.setMaximumFractionDigits(2); |
149 |
|
nf.setMinimumFractionDigits(2); |
150 |
|
String strCurValue = nf.format(curValue); |
151 |
|
|
152 |
|
// set the attributeName nicely |
153 |
< |
String attributeName = type + " Memory in use"; |
153 |
> |
String attributeName = type + " Memory in use " + type; |
154 |
|
if(useCache) { |
155 |
|
attributeName += " (ex. cache)"; |
156 |
|
} |