13 |
|
* @author $Author$ |
14 |
|
* @version $Id$ |
15 |
|
*/ |
16 |
< |
public class CPU__Monitor implements Monitor { |
16 |
> |
public class CPU__Monitor implements PluginMonitor { |
17 |
|
|
18 |
|
//---FINAL ATTRIBUTES--- |
19 |
|
|
49 |
|
//---PUBLIC METHODS--- |
50 |
|
|
51 |
|
public void analysePacket(XMLPacket packet) { |
52 |
< |
String source = packet.getParam("packet.attributes.hostname"); |
53 |
< |
for(int x=0; x < _levels.length; x++) { |
54 |
< |
if (_levels[x] != -1) { |
55 |
< |
double idle = Double.parseDouble(packet.getParam("packet.cpu.idle")); |
56 |
< |
if (_levels[x] < idle) fireAlert(x, source, idle, "idle"); |
57 |
< |
double user = Double.parseDouble(packet.getParam("packet.cpu.user")); |
58 |
< |
if (_levels[x] < user) fireAlert(x, source, user, "user"); |
59 |
< |
double kernel = Double.parseDouble(packet.getParam("packet.cpu.kernel")); |
60 |
< |
if (_levels[x] < kernel) fireAlert(x, source, kernel, "kernel"); |
61 |
< |
double iowait = Double.parseDouble(packet.getParam("packet.cpu.iowait")); |
62 |
< |
if (_levels[x] < iowait) fireAlert(x, source, iowait, "iowait"); |
63 |
< |
double swap = Double.parseDouble(packet.getParam("packet.cpu.swap")); |
64 |
< |
if (_levels[x] < swap) fireAlert(x, source, swap, "swap"); |
52 |
> |
if (packet.getParam("packet.attributes.type").equals("data")) { |
53 |
> |
String source = packet.getParam("packet.attributes.hostname"); |
54 |
> |
for(int x=0; x < _levels.length; x++) { |
55 |
> |
if (_levels[x] != -1) { |
56 |
> |
double idle = Double.parseDouble(packet.getParam("packet.cpu.idle")); |
57 |
> |
if (_levels[x] < idle) fireAlert(x, source, idle, "idle"); |
58 |
> |
double user = Double.parseDouble(packet.getParam("packet.cpu.user")); |
59 |
> |
if (_levels[x] < user) fireAlert(x, source, user, "user"); |
60 |
> |
double kernel = Double.parseDouble(packet.getParam("packet.cpu.kernel")); |
61 |
> |
if (_levels[x] < kernel) fireAlert(x, source, kernel, "kernel"); |
62 |
> |
double iowait = Double.parseDouble(packet.getParam("packet.cpu.iowait")); |
63 |
> |
if (_levels[x] < iowait) fireAlert(x, source, iowait, "iowait"); |
64 |
> |
double swap = Double.parseDouble(packet.getParam("packet.cpu.swap")); |
65 |
> |
if (_levels[x] < swap) fireAlert(x, source, swap, "swap"); |
66 |
> |
} |
67 |
|
} |
68 |
|
} |
69 |
|
} |
99 |
|
String attributeName = "CPU " + type; |
100 |
|
Alert alert = new Alert(alertLevel, source, thresholdValue, value, attributeName); |
101 |
|
_alerterQueue.add(alert); |
102 |
+ |
_logger.write(toString(), Logger.DEBUG, "Fired alert for source:" + source + " at alert level:" + alertLevel + " on:" + type + " at:" + currentValue + " exceeding threshold:" + _levels[alertLevel]); |
103 |
|
} |
104 |
|
|
105 |
|
//---ACCESSOR/MUTATOR METHODS--- |