Exemplo n.º 1
0
 public Vector getScalarValues(ScalarProperty scalarproperty, HTTPRequest httprequest, CGI cgi)
     throws SiteViewException {
   if (scalarproperty == pItems) {
     SiteViewGroup siteviewgroup = SiteViewGroup.currentSiteView();
     Array array = CGI.getAllowedGroupIDsForAccount(httprequest);
     Enumeration enumeration = array.elements();
     Vector vector1 = new Vector();
     Vector vector2 = new Vector();
     String s = getFullID();
     while (enumeration.hasMoreElements()) {
       MonitorGroup monitorgroup =
           (MonitorGroup) siteviewgroup.getElement((String) enumeration.nextElement());
       if (monitorgroup != null) {
         Enumeration enumeration2 = monitorgroup.getMonitors();
         while (enumeration2.hasMoreElements()) {
           Monitor monitor = (Monitor) enumeration2.nextElement();
           if (!(monitor instanceof SubGroup)
               && !s.equals(monitor.getFullID())
               && ("SNMPMonitor".equals(monitor.getClassProperty("class"))
                   || (monitor instanceof BandwidthMonitor)
                   || "ScriptMonitor".equals(monitor.getClassProperty("class"))
                   || "NTCounterMonitor".equals(monitor.getClassProperty("class"))
                   || "DatabaseMonitor".equals(monitor.getClassProperty("class")))) // dingbing.xu
           {
             vector2.addElement(monitor.getProperty(pGroupID) + " " + monitor.getProperty(pID));
             vector2.addElement(
                 monitorgroup.getProperty(pName) + ": " + monitor.getProperty(pName));
           }
         }
       }
     }
     for (Enumeration enumeration1 = vector2.elements();
         enumeration1.hasMoreElements();
         vector1.addElement(enumeration1.nextElement())) {}
     return vector1;
   } else if (scalarproperty == pOperation) {
     Vector vector = new Vector();
     vector.addElement("Add");
     vector.addElement("Add");
     vector.addElement("Multiply");
     vector.addElement("Multiply");
     vector.addElement("Subtract12");
     vector.addElement("Subtract 1 from 2");
     vector.addElement("Subtract21");
     vector.addElement("Subtract 2 from 1");
     vector.addElement("Divide12");
     vector.addElement("Divide 1 by 2");
     vector.addElement("Divide21");
     vector.addElement("Divide 2 by 1");
     return vector;
   } else {
     return super.getScalarValues(scalarproperty, httprequest, cgi);
   }
 }
Exemplo n.º 2
0
 protected Array getMonitorsToRun() {
   HashMap hashmap = new HashMap();
   Array array = new Array();
   SiteViewGroup siteviewgroup = SiteViewGroup.currentSiteView();
   Enumeration enumeration = getMultipleValues(pItems);
   label0:
   do {
     if (!enumeration.hasMoreElements()) {
       break;
     }
     String s = (String) enumeration.nextElement();
     String as[] = TextUtils.split(s);
     Object obj = null;
     Object obj1 = null;
     if (as.length == 1) {
       MonitorGroup monitorgroup = (MonitorGroup) siteviewgroup.getElement(as[0]);
       if (monitorgroup == null) {
         continue;
       }
       Enumeration enumeration1 = monitorgroup.getMonitors();
       do {
         Monitor monitor;
         do {
           if (!enumeration1.hasMoreElements()) {
             continue label0;
           }
           monitor = (Monitor) enumeration1.nextElement();
         } while (!(monitor instanceof AtomicMonitor));
         addToMonitorList(monitor, array, hashmap);
       } while (true);
     }
     if (as.length > 1) {
       String s1 = as[0] + SiteViewGroup.ID_SEPARATOR + as[1];
       MonitorGroup monitorgroup1 = (MonitorGroup) siteviewgroup.getElement(as[0]);
       if (monitorgroup1 != null) {
         Monitor monitor1 = (Monitor) siteviewgroup.getElement(s1);
         if (monitor1 != null) {
           addToMonitorList(monitor1, array, hashmap);
         }
       }
     }
   } while (true);
   return array;
 }
Exemplo n.º 3
0
 protected boolean update() {
   double ad[] = initializeStats();
   String as[] = initializeNameList();
   Enumeration enumeration = getMultipleValues(pItems);
   SiteViewGroup siteviewgroup = SiteViewGroup.currentSiteView();
   long l = getPropertyAsLong(pDelay) * 1000L;
   String s = getProperty(pStatic);
   s = s.trim();
   if (getPropertyAsBoolean(pRunMonitors)) {
     checkSequentially(ad, as, l, "");
   } else {
     int i = 0;
     do {
       if (!enumeration.hasMoreElements()) {
         break;
       }
       String s2 = (String) enumeration.nextElement();
       Monitor monitor = (Monitor) siteviewgroup.getElement(s2.replace(' ', '/'));
       if (monitor != this) {
         if (monitor != null) {
           if (!(monitor instanceof MonitorGroup)) {
             updateStats(ad, as, monitor, i++);
           }
         } else {
           LogManager.log(
               "Error",
               "Could not get monitor " + s2 + " in Composite Monitor " + getProperty(pName));
         }
       }
     } while (true);
   }
   String s1 = getProperty(pOperation);
   double d = 0.0D;
   double d1 = ad[0];
   double d2 = ad[1];
   String s3 = "";
   String s4 = "ok";
   if (s1.equals("Add")) {
     if (d1 != -999D && d2 != -999D) {
       d = d1 + d2;
       s3 = s3 + as[0] + " = " + d1 + ", " + as[1] + " = " + d2 + ", Add Result= " + d;
     } else {
       s4 = "n/a";
       s3 = s3 + " Add Result= n/a";
     }
   } else if (s1.equals("Multiply")) {
     if (d1 != -999D && d2 != -999D) {
       d = d1 * d2;
       s3 = s3 + as[0] + " = " + d1 + ", " + as[1] + " = " + d2 + ", Multiply Result= " + d;
     } else {
       s4 = "n/a";
       s3 = s3 + " Multiply Result= n/a";
     }
   } else if (s1.equals("Subtract12")) {
     if (d1 != -999D && d2 != -999D) {
       d = d1 - d2;
       s3 = s3 + as[0] + " = " + d1 + ", " + as[1] + " = " + d2 + ", Subtract Result= " + d;
     } else {
       s4 = "n/a";
       s3 = s3 + " Subtract Result= n/a";
     }
   } else if (s1.equals("Subtract21")) {
     if (d1 != -999D && d2 != -999D) {
       d = d2 - d1;
       s3 = s3 + as[0] + " = " + d1 + ", " + as[1] + " = " + d2 + ", Subtract Result= " + d;
     } else {
       s4 = "n/a";
       s3 = s3 + " Subtract Result= n/a";
     }
   } else if (s1.equals("Divide12")) {
     if (d1 != -999D && d2 != -999D && d2 != 0.0D) {
       d = d1 / d2;
       s3 = s3 + as[0] + " = " + d1 + ", " + as[1] + " = " + d2 + ", Divide Result= " + d;
     } else {
       s4 = "n/a";
       s3 = s3 + " Divide Result= n/a";
     }
   } else if (s1.equals("Divide21")) {
     if (d1 != -999D && d2 != -999D && d1 != 0.0D) {
       d = d2 / d1;
       s3 = s3 + as[0] + " = " + d1 + ", " + as[1] + " = " + d2 + ", Divide Result= " + d;
     } else {
       s4 = "n/a";
       s3 = s3 + " Divide Result= n/a";
     }
   }
   if (!s4.equals("n/a") && s.length() > 0) {
     String s5 = s.substring(0, 1);
     s = s.substring(1);
     if (s.length() > 0) {
       double d3 = TextUtils.toDouble(s);
       if (d3 != 0.0D && d != -999D) {
         if (s5.equals("+")) {
           d += d3;
         } else if (s5.equals("*")) {
           d *= d3;
         } else if (s5.equals("-")) {
           d -= d3;
         } else if (s5.equals("/")) {
           d /= d3;
         }
       }
     }
     int j = s3.indexOf("Result= ");
     s3 = s3.substring(0, j) + "Result= " + d;
   }
   if (stillActive()) {
     synchronized (this) {
       if (s4.equals("ok")) {
         setProperty(pResult, String.valueOf(d));
         setProperty(pStatus, s4);
         if (getProperty(pValueLabels).length() > 0) {
           setProperty(pStateString, s3 + ", " + (String) getLabels().get("result") + " = " + d);
         } else {
           setProperty(pStateString, s3);
         }
       } else {
         setProperty(pResult, "n/a");
         setProperty(pStatus, "n/a");
         setProperty(pNoData, "n/a");
         setProperty(pStateString, s3);
       }
     }
   }
   return true;
 }