root/src/java/src/com/omniti/reconnoiter/event/NoitMetric.java

Revision e8b241b833cdda315cc463b322a89ba888c5e781, 2.2 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 5 years ago)

juggle files around for cleaner builds.

  • Property mode set to 100644
Line 
1 /*
2  * Copyright (c) 2009, OmniTI Computer Consulting, Inc.
3  * All rights reserved.
4  * The software in this package is published under the terms of the GPL license
5  * a copy of which can be found at:
6  * https://labs.omniti.com/reconnoiter/trunk/src/java/LICENSE
7  */
8
9 package com.omniti.reconnoiter.event;
10
11 import com.omniti.reconnoiter.IEventHandler;
12 import com.omniti.reconnoiter.StratconMessage;
13 import com.omniti.reconnoiter.event.NoitMetricNumeric;
14 import com.omniti.reconnoiter.event.NoitMetricText;
15 import org.apache.log4j.Logger;
16
17 public class NoitMetric extends NoitEvent
18        implements NoitMetricGeneric {
19   static Logger logger = Logger.getLogger(NoitMetric.class.getName());
20   public final static String METRIC_STRING = "s";
21
22   private NoitMetricText nmt;
23   private NoitMetricNumeric nmn;
24  
25   public NoitMetric() {}
26   public NoitMetric(String[] parts) throws Exception {
27     super(parts);
28     if (parts[5].equals(METRIC_STRING)) {
29       nmn = null;
30       nmt = new NoitMetricText(parts);
31     }
32     else {
33       nmn = new NoitMetricNumeric(parts);
34       nmt = null;
35     }
36   }
37   public void handle(IEventHandler eh) {
38     long start = System.nanoTime();
39     if(nmn != null) eh.sendEvent(nmn);
40     if(nmt != null) eh.sendEvent(nmt);
41     long nanos = System.nanoTime() - start;
42     logger.debug("sendEvent("+getUuid()+"-"+getName()+") took "+(nanos/1000)+"us");
43   }
44   public String getUuid() { return (nmn != null)?nmn.getUuid():nmt.getUuid(); }
45   public String getName() { return (nmn != null)?nmn.getName():nmt.getName(); }
46   public long getTime() { return (nmn != null)?nmn.getTime():nmt.getTime(); }
47   public String getNoit() { return (nmn != null)?nmn.getNoit():nmt.getNoit(); }
48   public String getCheck_target() { return (nmn != null)?nmn.getCheck_target():nmt.getCheck_target(); }
49   public String getCheck_module() { return (nmn != null)?nmn.getCheck_module():nmt.getCheck_module(); }
50   public String getCheck_name() { return (nmn != null)?nmn.getCheck_name():nmt.getCheck_name(); }
51
52   public boolean isNumeric() { return nmn != null; }
53   public boolean isText() { return nmt != null; }
54   public NoitMetricNumeric getNumeric() { return nmn; }
55   public NoitMetricText getText() { return nmt; }
56   public String getPrefix() { return "M"; }
57   public int numparts() { return 7; }
58 }
Note: See TracBrowser for help on using the browser.