68 |
|
public void run() { |
69 |
|
while(_running) { |
70 |
|
try { |
71 |
< |
analysePacket((XMLPacket) getQueue().get(getQueueId())); |
71 |
> |
// check if monitoring is enabled for this host |
72 |
> |
// if not - just don't bother analyse it's packets |
73 |
> |
XMLPacket packet = (XMLPacket) getQueue().get(getQueueId()); |
74 |
> |
String source = packet.getParam("packet.attributes.machine_name"); |
75 |
> |
boolean enabled = checkBooleanConfig(source, "Monitor.enable"); |
76 |
> |
if(enabled) { |
77 |
> |
analysePacket(packet); |
78 |
> |
} |
79 |
|
} catch (InvalidQueueException e) { |
80 |
|
_logger.write(this.toString(), Logger.ERROR, "Unable to get queue."); |
81 |
|
} |
155 |
|
*/ |
156 |
|
public abstract String getDescription(); |
157 |
|
|
158 |
+ |
/** |
159 |
+ |
* Checks a boolean configuration variable. |
160 |
+ |
* |
161 |
+ |
* @param source the configuration to look up |
162 |
+ |
* @param name the key to look up |
163 |
+ |
*/ |
164 |
+ |
protected boolean checkBooleanConfig(String source, String name) { |
165 |
+ |
boolean enabled = true; |
166 |
+ |
try { |
167 |
+ |
int e = Integer.parseInt(_cp.getProperty(source, name)); |
168 |
+ |
enabled = (e == 1); |
169 |
+ |
} catch (PropertyNotFoundException e) { |
170 |
+ |
enabled = false; |
171 |
+ |
} catch (NumberFormatException e) { |
172 |
+ |
enabled = false; |
173 |
+ |
} |
174 |
+ |
return enabled; |
175 |
+ |
} |
176 |
|
|
177 |
|
//---PRIVATE METHODS--- |
178 |
|
|
239 |
|
* all new alerts will be placed. |
240 |
|
*/ |
241 |
|
protected Queue _alerterQueue = AlerterManager.getInstance().getQueue(); |
242 |
< |
|
242 |
> |
|
243 |
> |
/** |
244 |
> |
* A reference to the configuration proxy in use |
245 |
> |
*/ |
246 |
> |
private ConfigurationProxy _cp = ConfigurationProxy.getInstance(); |
247 |
> |
|
248 |
|
/** |
249 |
|
* The ID of the queue the monitor will use. |
250 |
|
* Initially -1, but initialised on first use. |