ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/client/MonitorSkeleton.java
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/client/MonitorSkeleton.java (file contents):
Revision 1.16 by tdb, Mon Feb 24 20:18:48 2003 UTC vs.
Revision 1.17 by tdb, Thu Jan 15 13:41:47 2004 UTC

# Line 68 | Line 68 | public abstract class MonitorSkeleton extends Thread i
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              }
# Line 148 | Line 155 | public abstract class MonitorSkeleton extends Thread i
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  
# Line 214 | Line 239 | public abstract class MonitorSkeleton extends Thread i
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.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines