1 |
|
//---PACKAGE DECLARATION--- |
2 |
< |
package uk.ac.ukc.iscream.client.monitors; |
2 |
> |
package uk.org.iscream.client.monitors; |
3 |
|
|
4 |
|
//---IMPORTS--- |
5 |
|
import java.util.HashMap; |
6 |
< |
import uk.ac.ukc.iscream.client.*; |
7 |
< |
import uk.ac.ukc.iscream.core.*; |
8 |
< |
import uk.ac.ukc.iscream.util.*; |
9 |
< |
import uk.ac.ukc.iscream.componentmanager.*; |
6 |
> |
import uk.org.iscream.client.*; |
7 |
> |
import uk.org.iscream.core.*; |
8 |
> |
import uk.org.iscream.util.*; |
9 |
> |
import uk.org.iscream.componentmanager.*; |
10 |
|
|
11 |
|
/** |
12 |
|
* This Monitor watches the CPU load for all machines |
35 |
|
if (packet.getParam("packet.attributes.type").equals("data")) { |
36 |
|
String source = packet.getParam("packet.attributes.machine_name"); |
37 |
|
if (!_hosts.containsKey(source)) { |
38 |
< |
_hosts.put(source, new Register(source, _name, _attributes.length)); |
38 |
> |
HashMap attributeRegisters = new HashMap(); |
39 |
> |
initAttributeRegsiters(source, attributeRegisters); |
40 |
> |
_hosts.put(source, attributeRegisters); |
41 |
|
} |
42 |
< |
|
43 |
< |
Register reg = (Register) _hosts.get(source); |
42 |
> |
|
43 |
> |
HashMap attributeRegisters = (HashMap) _hosts.get(source); |
44 |
|
for(int attributeNum = 0; attributeNum < _attributes.length; attributeNum++) { |
45 |
+ |
Register reg = (Register) attributeRegisters.get(_attributes[attributeNum]); |
46 |
|
// find out the threshold level we're at |
47 |
|
String attribute = _attributes[attributeNum]; |
48 |
|
String attributeName = _attributeNames[attributeNum]; |
49 |
|
String currentValue = packet.getParam(attribute); |
50 |
|
int newThreshold = checkAttributeThreshold(currentValue, reg); |
51 |
< |
processAlert(newThreshold, attributeNum, attributeName, reg, source, currentValue); |
51 |
> |
processAlert(newThreshold, attributeName, reg, source, currentValue); |
52 |
|
} |
53 |
|
} |
54 |
|
} |
57 |
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
58 |
|
* method to provide clean logging (every class should have this). |
59 |
|
* |
60 |
< |
* This uses the uk.ac.ukc.iscream.util.NameFormat class |
60 |
> |
* This uses the uk.org.iscream.util.NameFormat class |
61 |
|
* to format the toString() |
62 |
|
* |
63 |
|
* @return the name of this class and its CVS revision |
93 |
|
} |
94 |
|
} |
95 |
|
return Alert.thresholdNORMAL; |
96 |
+ |
} |
97 |
+ |
|
98 |
+ |
private void initAttributeRegsiters(String source, HashMap attributeRegisters) { |
99 |
+ |
for(int attributeNum = 0; attributeNum < _attributes.length; attributeNum++) { |
100 |
+ |
String attributeName = _attributes[attributeNum].substring(_attributes[attributeNum].lastIndexOf(".") + 1); |
101 |
+ |
attributeRegisters.put(_attributes[attributeNum], new Register(source, _name, attributeName)); |
102 |
+ |
} |
103 |
|
} |
104 |
|
|
105 |
|
//---ACCESSOR/MUTATOR METHODS--- |