Ejemplo n.º 1
0
 public XmlApiRequestXML(String s) {
   xmlResponse = null;
   xmlRequest = null;
   encodeValues = true;
   if (debug) {
     System.out.println("xmlRequest=" + s);
   }
   xmlRequest = s;
   javax.xml.parsers.DocumentBuilderFactory documentbuilderfactory =
       javax.xml.parsers.DocumentBuilderFactory.newInstance();
   org.w3c.dom.Document document = null;
   try {
     javax.xml.parsers.DocumentBuilder documentbuilder =
         documentbuilderfactory.newDocumentBuilder();
     document = documentbuilder.parse(new InputSource(new StringReader(s)));
   } catch (Exception exception) {
     com.dragonflow.Log.LogManager.log(
         "Error", "SiteView API: Exception, " + exception.getMessage());
     return;
   }
   if (document.getDocumentElement() != null) {
     encodeValues = true;
     processNode(document.getDocumentElement(), request);
   } else {
     com.dragonflow.Log.LogManager.log("error", "APIRequestXML: Document element is null");
   }
 }
Ejemplo n.º 2
0
  /**
   * CAUTION: Decompiled by hand.
   *
   * @param s
   * @param s1
   * @return
   */
  public static String UnicodeToString(String s, String s1) {
    try {
      if (s == null) return "";
      if (!isI18N(s)) /* change by dingbing.xu from isI18N */ {
        return s;
      }

      if (s1 == com.dragonflow.Utils.I18N.nullEncoding()) {
        com.dragonflow.Utils.I18N.test(s, 1);
      } else if (s1.length() == 0) {
        com.dragonflow.Utils.I18N.test(s, 0);
      }
      String s2;
      byte abyte0[] = s1 != null && s1.length() != 0 ? s.getBytes(s1) : s.getBytes();
      char ac[] = new char[abyte0.length];
      for (int i = 0; i < abyte0.length; i++) {
        ac[i] = (char) (abyte0[i] & 0xff);
      }

      s2 = new String(ac);
      com.dragonflow.Utils.I18N.test(s2, 2);
      return s2;
    } catch (Exception exception) {
      if (s1 != null && s1.length() > 0) {
        com.dragonflow.Log.LogManager.log(
            "Error", "I18N: Bad Encoding(" + s1 + ") " + exception.getMessage());
        com.dragonflow.Utils.TextUtils.debugPrint(
            "I18N: Bad Encoding(" + s1 + ") " + exception.getMessage());
        exception.printStackTrace();
      }
      return s;
    }
  }
Ejemplo n.º 3
0
 public void getMetricData(boolean flag) {
   java.lang.String s;
   try {
     s = doRequest("/?id=11&type=0", false, null);
   } catch (java.lang.Exception exception) {
     com.dragonflow.Log.LogManager.log(
         "error",
         "J2EEConnection: Failed to retrieve data from target "
             + getConnID()
             + ": "
             + exception.getMessage());
     lastError = "Failed to retrieve data from server: " + exception.getMessage();
     return;
   }
   if (s.indexOf("Results are null. No measurements were selected") >= 0) {
     if (flag) {
       com.dragonflow.Log.LogManager.log(
           "RunMonitor",
           "J2EEConnection: No measuements were selected for target "
               + getConnID()
               + ". Reposting metric list.");
       postMetricList();
       getMetricData(false);
     } else {
       com.dragonflow.Log.LogManager.log(
           "error",
           "J2EEConnection: No measuements were selected for target "
               + getConnID()
               + ". Reposting metric list did not solve problem. Aborting...");
       lastError = "Internal error, see log for details";
     }
   } else {
     try {
       handleMetricData(s);
       lastError = null;
     } catch (java.lang.Exception exception1) {
       exception1.printStackTrace();
       com.dragonflow.Log.LogManager.log(
           "error",
           "J2EEConnection: Error while parsing metric data from "
               + getConnID()
               + ": "
               + exception1.getMessage());
       lastError = "Failed to parse metric data: " + exception1.getMessage();
     }
   }
 }
Ejemplo n.º 4
0
  public void postMetricList() {
    try {
      doRequest("/?id=10&type=0", true, null);
    } catch (java.lang.Exception exception) {
      com.dragonflow.Log.LogManager.log(
          "error",
          "J2EEConnection: Failed to post metric list target "
              + getConnID()
              + ": "
              + exception.getMessage());
      return;
    }
    TreeNode treenode = new TreeNode(xmlKeys);
    for (java.util.Iterator iterator = counterUnion.values().iterator(); iterator.hasNext(); ) {
      java.lang.String as[] = (java.lang.String[]) iterator.next();
      try {
        treenode.addNode(as);
      } catch (java.lang.Exception exception1) {
        exception1.printStackTrace();
      }
    }

    java.lang.StringBuffer stringbuffer = new StringBuffer();
    treenode.toXML(stringbuffer);
    java.lang.StringBuffer stringbuffer1 = new StringBuffer();
    try {
      doRequest("/?id=12&type=0", false, stringbuffer.toString());
    } catch (java.lang.Exception exception2) {
      com.dragonflow.Log.LogManager.log(
          "error",
          "J2EEConnection: Failed to post metric list target "
              + getConnID()
              + ": "
              + exception2.getMessage());
    }
  }
Ejemplo n.º 5
0
 void initializeDatabase() {
   com.dragonflow.Properties.JdbcConfig.inInitStage = true;
   boolean flag = false;
   com.dragonflow.Log.LogManager.log(
       "RunMonitor", "jdbc config, initializing database from configuration files");
   try {
     com.dragonflow.Properties.JdbcConfig.getJdbcConfig();
     com.dragonflow.Properties.JdbcConfig.syncDBFromFiles();
     com.dragonflow.Properties.JdbcConfig.inInitStage = false;
     return;
   } catch (Exception exception) {
     if (!flag) {
       printErrorPage("Could not sync from db " + exception.getMessage());
     }
   }
 }
Ejemplo n.º 6
0
  /**
   * CAUTION: Decompiled by hand.
   *
   * @param abyte0
   * @return
   */
  public static String byteString(byte abyte0[]) {
    if (!isI18N) {
      return new String(abyte0);
    }
    try {
      String s;
      char ac[] = new char[abyte0.length];
      for (int i = 0; i < abyte0.length; i++) {
        ac[i] = (char) (abyte0[i] & 0xff);
      }

      s = new String(ac);
      return s;
    } catch (Exception exception) {
      com.dragonflow.Log.LogManager.log("Error", "I18N: Cannot Encode " + exception.getMessage());
      com.dragonflow.Utils.TextUtils.debugPrint("I18N: Cannot Encode " + exception.getMessage());
      exception.printStackTrace();
      return "";
    }
  }
Ejemplo n.º 7
0
  /**
   * CAUTION: Decompiled by hand.
   *
   * @param s
   * @param s1
   * @return
   */
  public static String StringToUnicode(String s, String s1) {
    if (s == null || s.length() == 0) {
      return "";
    }

    if (!isI18N(s)) /*change By dingbing.xu*/ {
      return s;
    }
    String s2 = "";
    com.dragonflow.Utils.I18N.test(s, 2);
    String s3;

    try {
      byte abyte0[] = new byte[s.length()];
      for (int i = 0; i < s.length(); i++) {
        abyte0[i] = (byte) (s.charAt(i) & 0xff);
      }

      s3 = s1 != null && s1.length() != 0 ? new String(abyte0, s1) : new String(abyte0);
      if (s1 == com.dragonflow.Utils.I18N.nullEncoding()) {
        com.dragonflow.Utils.I18N.test(s3, 1);
      } else if (s1.length() == 0) {
        com.dragonflow.Utils.I18N.test(s3, 0);
      }
      return s3;
    } catch (Exception exception) {
      if (s1 != null && s1.length() > 0) {
        com.dragonflow.Log.LogManager.log(
            "Error", "I18N: Bad Encoding(" + s1 + ") " + exception.getMessage());
        com.dragonflow.Utils.TextUtils.debugPrint(
            "I18N: Bad Encoding(" + s1 + ") " + exception.getMessage());
        exception.printStackTrace();
      }
      return s;
    }
  }
Ejemplo n.º 8
0
  private void handleMetricData(java.lang.String s) throws java.lang.Exception {
    long l = java.lang.System.currentTimeMillis() / 1000L;
    org.w3c.dom.Document document = documentBuilder.parse(new InputSource(new StringReader(s)));
    org.w3c.dom.NodeList nodelist =
        document.getElementsByTagName((java.lang.String) xmlKeys.get("counter"));
    int i = nodelist.getLength();
    java.util.HashMap hashmap = new HashMap();
    for (int j = 0; j < i; j++) {
      org.w3c.dom.Element element = (org.w3c.dom.Element) nodelist.item(j);
      if (element.getAttribute((java.lang.String) xmlKeys.get("name")).equals("HPS")) {
        continue;
      }
      org.w3c.dom.Element element1 = (org.w3c.dom.Element) element.getParentNode();
      java.util.Map map = getValuesFromObject(element1);
      java.util.HashMap hashmap1 = new HashMap();
      jgl.Array array = new Array();
      for (org.w3c.dom.Element element2 = element1;
          element2.getTagName().equals((java.lang.String) xmlKeys.get("object"));
          element2 = (org.w3c.dom.Element) element2.getParentNode()) {
        java.lang.String s4 = element2.getAttribute((java.lang.String) xmlKeys.get("class"));
        java.lang.String s5 = (java.lang.String) xmlToLong.get(s4);
        if (s5 == null) {
          s5 = s4;
        }
        java.lang.String s6 = element2.getAttribute((java.lang.String) xmlKeys.get("name"));
        hashmap1.put(s5, s6);
        array.add(s5 + ": " + s6);
      }

      java.lang.String s2 = J2EEConnection.getNameFromArray(array);
      hashmap.put(s2, new SampleData(hashmap1, map));
    }

    for (java.util.Iterator iterator = activeMonitors.entrySet().iterator(); iterator.hasNext(); ) {
      java.util.Map.Entry entry = (java.util.Map.Entry) iterator.next();
      java.lang.String s1 = (java.lang.String) entry.getKey();
      Monitor monitor = (Monitor) entry.getValue();
      java.util.Set set = monitor.getCounters();
      java.util.LinkedList linkedlist = new LinkedList();
      java.lang.String s3 = java.lang.String.valueOf(l);
      boolean flag = false;
      for (java.util.Iterator iterator1 = set.iterator(); iterator1.hasNext(); ) {
        java.lang.String s7 = (java.lang.String) iterator1.next();
        SampleData sampledata = (SampleData) hashmap.get(s7);
        if (sampledata == null) {
          java.lang.System.out.println(
              "J2EEConnection " + getConnID() + "/" + s1 + ": Counter missing - " + s7);
          flag = true;
        } else {
          //                    com.dragonflow.topaz.j2ee.comm.HashedSample hashedsample = new
          // HashedSample(l, "J2EEMonitor");
          java.util.Map.Entry entry1;
          //                    for(java.util.Iterator iterator2 =
          // sampledata.values.entrySet().iterator(); iterator2.hasNext();
          // hashedsample.addValue((java.lang.String)entry1.getKey(), entry1.getValue()))
          //                    {
          //                        entry1 = (java.util.Map.Entry)iterator2.next();
          //                    }

          //                    hashedsample.addValue("TimeStamp", new Double(l));
          //                    hashedsample.setMeasurementValue("Monitor", "J2EEMonitor");
          //                    hashedsample.setMeasurementValue("TimeStamp", s3);
          //                    java.util.Map.Entry entry2;
          //                    for(java.util.Iterator iterator3 =
          // sampledata.measurment.entrySet().iterator(); iterator3.hasNext();
          // hashedsample.setMeasurementValue((java.lang.String)entry2.getKey(),
          // (java.lang.String)entry2.getValue()))
          //                    {
          //                        entry2 = (java.util.Map.Entry)iterator3.next();
          //                    }
          //
          //                    linkedlist.add(hashedsample);
        }
      }

      if (flag) {
        com.dragonflow.Log.LogManager.log("error", "Monitor: " + s1 + " missing counter");
        monitor.setLastError(
            "Probe is out of sync. This is probably due to a second client (such as SiteView or LoadRunner) running against the same probe. To resolve this, shut down the unwanted client and repost metrics from the Tools link on this row.");
      } else {
        monitor.setLastError(null);
      }
      //            com.dragonflow.topaz.j2ee.configuration.CheckSampleChunkResult
      // checksamplechunkresult = aggregationConfigurator.checkSampleChunk(linkedlist);
      //            java.util.ArrayList arraylist =
      // checksamplechunkresult.getResultListByAggregatorId("SiteViewAggregator");
      //            synchronized(monitor)
      //            {
      //                if(arraylist != null)
      //                {
      //                    monitor.getAggregator().addChunk(arraylist);
      //                    monitor.setHasResults(true);
      //                }
      //            }
    }
  }
Ejemplo n.º 9
0
 private void saveSettings() {
   printPageHeader();
   //        com.dragonflow.TopazWatchdog.TopazHostsConfigurator.init();
   boolean flag = false;
   String s = request.getValue("monitoredHostsTypeMask");
   String s1 = request.getValue("disabledHostsIds");
   String s2 = request.getValue("enabledHostsIds");
   try {
     int i = Integer.parseInt(s);
     //            int j = com.dragonflow.TopazWatchdog.WatchdogConfig.getMonitoredHostsTypeMask();
     //            if(j != i)
     //            {
     //                com.dragonflow.TopazWatchdog.WatchdogConfig.setMonitoredHostsTypeMask(i);
     //                flag = true;
     //            }
     java.util.StringTokenizer stringtokenizer = null;
     stringtokenizer = new StringTokenizer(s1, ",", false);
     do {
       if (!stringtokenizer.hasMoreTokens()) {
         break;
       }
       String s6 = stringtokenizer.nextToken();
       //                if(com.dragonflow.TopazWatchdog.WatchdogConfig.addToDisabledHosts(s6))
       //                {
       //                    flag = true;
       //                }
     } while (true);
     stringtokenizer = new StringTokenizer(s2, ",", false);
     do {
       if (!stringtokenizer.hasMoreTokens()) {
         break;
       }
       String s7 = stringtokenizer.nextToken();
       //
       // if(com.dragonflow.TopazWatchdog.WatchdogConfig.removeFromDisabledHosts(s7))
       //                {
       //                    flag = true;
       //                }
     } while (true);
   } catch (NumberFormatException numberformatexception) {
     com.dragonflow.Log.LogManager.log(
         "TopazWatchdog", "Cannot parse Watchdog settings parameters.");
   }
   //        outputStream.println("<h3>" +
   // com.dragonflow.TopazWatchdog.WatchdogConfig.getWatchdogDisplayedName() + " Configuration
   // Result:</h3>");
   outputStream.flush();
   //        if(!com.dragonflow.TopazWatchdog.WatchdogConfig.isTopazWatchdogEnabled())
   //        {
   //            String s3 = com.dragonflow.TopazWatchdog.WatchdogConfig.getWatchdogDisplayedName()
   // + " was not configured. <BR>\n" + "Please <B>configure</B> " +
   // com.dragonflow.TopazWatchdog.WatchdogConfig.getWatchdogDisplayedName() + " and try
   // again.<BR>\n";
   //            outputStream.println(s3);
   //            outputStream.flush();
   //        } else
   //        if(flag)
   //        {
   //            com.dragonflow.TopazWatchdog.TopazHostsConfigurator.configureAll(true, true,
   // outputStream);
   //        } else
   //        {
   //            outputStream.println("Watchdog configuration remains unchanged.");
   //        }
   String s4 = getPageLink("twdPrefs", "showWatchdogSettings");
   //        outputStream.print("<P><A href=" + s4 + "> <B> Edit " +
   // com.dragonflow.TopazWatchdog.WatchdogConfig.getWatchdogDisplayedName() + " Settings </B>
   // </A>\n");
   String s5 = getPageLink("topazPrefs", "");
   //        outputStream.print("<P><A href=" + s5 + "> <B> " +
   // com.dragonflow.SiteView.TopazInfo.getTopazName() + " Server Registration </B> </A>\n");
   printFooter(outputStream);
 }