Пример #1
0
 public Vector getScalarValues(ScalarProperty scalarproperty, HTTPRequest httprequest, CGI cgi)
     throws SiteViewException {
   if (scalarproperty == pScript) {
     Vector vector =
         getScriptList(getProperty(pMachineName), getProperty(pLocalScriptLocation), httprequest);
     vector.addElement("USE COMMAND");
     vector.addElement("USE COMMAND");
     return vector;
   }
   if (scalarproperty == pRemoteScript) {
     Vector vector1 = new Vector();
     File file =
         new File(Platform.getUsedDirectoryPath("scripts.remote", httprequest.getAccount()));
     String as[] = file.list();
     if (as != null) {
       vector1.addElement("none");
       vector1.addElement("none");
       for (int i = 0; i < as.length; i++) {
         String s = I18N.toNullEncoding(as[i]);
         if (Platform.isUnix() && s.startsWith(".")) {
           continue;
         }
         File file1 = new File(file, as[i]);
         if (!file1.isDirectory()) {
           vector1.addElement(s);
           vector1.addElement(s);
         }
       }
     }
     return vector1;
   } else {
     return super.getScalarValues(scalarproperty, httprequest, cgi);
   }
 }
Пример #2
0
 public static Array getTemplateConfigFileList() {
   Array array = new Array();
   String s = Platform.getRoot() + "/groups/" + TEMPLATES_FILE;
   File file = new File(s);
   if (file.exists()) {
     array.add(s);
   }
   if (Platform.isPortal()) {
     Portal.addTemplateConfigFiles(array);
   }
   return array;
 }
Пример #3
0
 static {
   mandatoryProps = new TreeSet();
   mandatoryProps.add("_driver");
   mandatoryProps.add("_database");
   mandatoryProps.add("_select");
   mandatoryProps.add("_from");
   mandatoryProps.add("_emsTablePrimaryKeys");
   mandatoryProps.add("lastEmum");
   mandatoryProps.add("_user");
   mandatoryProps.add("_password");
   String xmlName = Platform.getRoot() + "/classes/COM/dragonflow/topaz/ems/JDBCSource/db.xml";
   StringProperty props[] = StaticInitializer.initialize(xmlName);
   pFieldType = new ScalarProperty("_fieldType");
   pFieldType.setParameterOptions(true, true, 10, false);
   pFieldType.setDisplayText("Enumerating Field Type", "type of field used to order this query");
   pStatus = new StringProperty("pMStatus");
   pStatus.setIsThreshold(false);
   Vector vec = new Vector(Arrays.asList(props));
   vec.add(pStatus);
   vec.add(pFieldType);
   PropertiedObject.addProperties(
       "COM.dragonflow.StandardMonitor.EMSDatabaseMonitor", (StringProperty[]) vec.toArray(props));
   SiteViewObject.addClassElement(
       "COM.dragonflow.StandardMonitor.EMSDatabaseMonitor",
       Rule.stringToClassifier("pMStatus == 2\terror", false));
   SiteViewObject.addClassElement(
       "COM.dragonflow.StandardMonitor.EMSDatabaseMonitor",
       Rule.stringToClassifier("pMStatus == 1\twarning", false));
   SiteViewObject.addClassElement(
       "COM.dragonflow.StandardMonitor.EMSDatabaseMonitor",
       Rule.stringToClassifier("pMStatus == 0\tgood", false));
   SiteViewObject.addClassElement(
       "COM.dragonflow.StandardMonitor.EMSDatabaseMonitor",
       Rule.stringToClassifier("always\tgood"));
   PropertiedObject.setClassProperty(
       "COM.dragonflow.StandardMonitor.EMSDatabaseMonitor",
       "description",
       "Sends Topaz data retireved from a database by connecting to it and performing a query.\t");
   PropertiedObject.setClassProperty(
       "COM.dragonflow.StandardMonitor.EMSDatabaseMonitor", "title", "EMS Database");
   PropertiedObject.setClassProperty(
       "COM.dragonflow.StandardMonitor.EMSDatabaseMonitor", "topazName", "EMS Database");
   handleEmsLicense("COM.dragonflow.StandardMonitor.EMSDatabaseMonitor");
   PropertiedObject.setClassProperty(
       "COM.dragonflow.StandardMonitor.EMSDatabaseMonitor", "class", "EMSDatabaseMonitor");
   PropertiedObject.setClassProperty(
       "COM.dragonflow.StandardMonitor.EMSDatabaseMonitor", "topazType", "System Resources");
   PropertiedObject.setClassProperty(
       "COM.dragonflow.StandardMonitor.EMSDatabaseMonitor", "help", "EMSDatabaseMonitor.htm");
   PropertiedObject.setClassProperty(
       "COM.dragonflow.StandardMonitor.EMSDatabaseMonitor", "toolName", "Database Connection");
   PropertiedObject.setClassProperty(
       "COM.dragonflow.StandardMonitor.EMSDatabaseMonitor",
       "toolDescription",
       "Provides an interface to test a JDBC or ODBC connection to a database.");
   PropertiedObject.setClassProperty(
       "COM.dragonflow.StandardMonitor.EMSDatabaseMonitor", "classType", "advanced");
 }
Пример #4
0
  public HashMap getTemplateTable() {
    if (templateID != null && templateTableLastUpdate < templateCacheLastUpdate) {
      templateTable = null;
      if (templateID.length() > 0) {
        if (templateCache == null) {
          templateCache = new HashMap();
          String s = "";
          Array array = getTemplateConfigFileList();
          for (int i = 0; i < array.size(); i++)
            try {
              s = (String) array.at(i);
              HashMap hashmap2 = new HashMap();
              Array array1 = FrameFile.readFromFile(s);
              templateCacheLastUpdate = Platform.timeMillis();
              for (int j = 1; j < array1.size(); j++) {
                HashMap hashmap3 = (HashMap) array1.at(j);
                hashmap2.put(TextUtils.getValue(hashmap3, "__id"), hashmap3);
              }

              resolveTemplateReferences(hashmap2);
              templateCache.add(s, hashmap2);
            } catch (IOException ioexception) {
              LogManager.log("Error", "Could not read template file " + s);
            }
        }
        if (templateCache != null) {
          String s1 = getTemplateConfigFilePath();
          HashMap hashmap = null;
          hashmap = (HashMap) templateCache.get(s1);
          if (hashmap != null) {
            HashMap hashmap1 = (HashMap) hashmap.get(templateID);
            if (hashmap1 != null) {
              templateTable = new HashMapOrdered(true);
              initializeValuesTable(hashmap1, templateTable, true);
            }
          }
        }
      }
      templateTableLastUpdate = Platform.timeMillis();
    }
    return templateTable;
  }
Пример #5
0
 public String getTestURL() {
   int i = Machine.getOS(getProperty(pMachineName));
   if (Platform.isWindows(i)) {
     String s = URLEncoder.encode(getProperty(pMachineName));
     String s1 =
         "/SiteView/cgi/go.exe/SiteView?page=perfCounter&counterObject=Memory&machineName=" + s;
     return s1;
   } else {
     return null;
   }
 }
Пример #6
0
  /**
   * CAUTION: Decompiled by hand.
   *
   * @param s
   * @return
   * @throws IOException
   */
  private String getCommandFromLocalFile(String s) throws IOException {
    String s1;
    s1 = (String) scriptCommands.get(s);
    if (s1 == null) {
      try {
        s1 =
            FileUtils.readFile(Platform.getUsedDirectoryPath("scripts.remote", "") + "//" + s)
                .toString();
      } catch (FileNotFoundException filenotfoundexception) {

        int i = 0;
        for (; i < 10; i++) {
          try {
            s1 =
                FileUtils.readFile(Platform.getUsedDirectoryPath("scripts.remote", "") + "//" + s)
                    .toString();
            if (s1 == null) {
              continue;
            }
          } catch (FileNotFoundException filenotfoundexception1) {
            try {
              Thread.currentThread();
              Thread.sleep(100L);
            } catch (InterruptedException interruptedexception) {
              interruptedexception.printStackTrace();
            }
          }
        }

        if (i == 10) {
          throw filenotfoundexception;
        }
      }
      scriptCommands.add(s, s1);
    }
    return s1;
  }
Пример #7
0
  static {
    Array array = new Array();
    pSAPServer = new StringProperty("_server", "");
    pSAPServer.setDisplayText("Server", "SAP server name.");
    pSAPServer.setParameterOptions(false, true, BrowsableBase.COUNTER_PROPERTY_INDEX + 1, false);
    array.add(pSAPServer);
    pSystem = new StringProperty("_system", "00");
    pSystem.setDisplayText("System", "Enter the System number for SAP");
    pSystem.setParameterOptions(false, true, BrowsableBase.COUNTER_PROPERTY_INDEX + 2, false);
    array.add(pSystem);
    pClient = new StringProperty("_client");
    pClient.setDisplayText("Client", "Enter the Client for SAP, leave blank for default");
    pClient.setParameterOptions(false, true, BrowsableBase.COUNTER_PROPERTY_INDEX + 3, false);
    array.add(pClient);
    pUsername = new StringProperty("_username");
    pUsername.setDisplayText("Username", "Enter the Username for SAP");
    pUsername.setParameterOptions(false, true, BrowsableBase.COUNTER_PROPERTY_INDEX + 4, false);
    array.add(pUsername);
    pPassword = new StringProperty("_password");
    pPassword.setDisplayText("Password", "Enter the Password for SAP");
    pUsername.setParameterOptions(false, true, BrowsableBase.COUNTER_PROPERTY_INDEX + 5, false);
    pPassword.isPassword = true;
    array.add(pPassword);
    StringProperty astringproperty[] = new StringProperty[array.size()];
    for (int i = 0; i < array.size(); i++) {
      astringproperty[i] = (StringProperty) array.at(i);
    }

    String s = (com.dragonflow.StandardMonitor.SAPMonitor.class).getName();
    addProperties(s, astringproperty);
    addClassElement(s, Rule.stringToClassifier("countersInError > 0\terror", true));
    addClassElement(s, Rule.stringToClassifier("always\tgood"));
    setClassProperty(s, "description", "Monitor statistics from a SAP application server");
    setClassProperty(s, "help", "SAPMon.htm");
    setClassProperty(s, "title", "SAP");
    setClassProperty(s, "class", "SAPMonitor");
    setClassProperty(s, "target", "_server");
    setClassProperty(s, "topazName", "SAP");
    setClassProperty(s, "classType", "application");
    setClassProperty(s, "topazType", "ERP");
    if (!Platform.isWindows()) {
      setClassProperty(s, "loadable", "false");
    }
  }
Пример #8
0
 static {
   returnURL = "/SiteView/cgi/go.exe/SiteView/?page=monitor&class=ASPMonitor";
   counterObjects = "Active Server Pages";
   pCounters = new StringProperty("_counters", "", "Selected Counters");
   pCounters.setDisplayText(
       "Counters",
       "the current selection of counters</TD></TR><TR><TD></TD><TD><A HREF=\"/SiteView/cgi/go.exe/SiteView/?page=counter&returnURL="
           + URLEncoder.encode(returnURL)
           + "&maxcounters="
           + nMaxCounters
           + "&counterobjects="
           + counterObjects
           + "&type=NTCounter\">choose counters</A>");
   pCounters.setParameterOptions(false, true, 1, false);
   pCounters.isMultiLine = true;
   StringProperty astringproperty[] = {pCounters};
   addProperties("com.dragonflow.StandardMonitor.ASPMonitor", astringproperty);
   addClassElement(
       "com.dragonflow.StandardMonitor.ASPMonitor",
       Rule.stringToClassifier("value0 == n/a\terror", true));
   addClassElement(
       "com.dragonflow.StandardMonitor.ASPMonitor", Rule.stringToClassifier("always\tgood"));
   setClassProperty(
       "com.dragonflow.StandardMonitor.ASPMonitor",
       "description",
       "Monitors Microsoft Active Server Pages server performance statistics.");
   setClassProperty("com.dragonflow.StandardMonitor.ASPMonitor", "help", "ASPServerMon.htm");
   setClassProperty("com.dragonflow.StandardMonitor.ASPMonitor", "title", "ASP Server");
   setClassProperty("com.dragonflow.StandardMonitor.ASPMonitor", "class", "ASPMonitor");
   setClassProperty("com.dragonflow.StandardMonitor.ASPMonitor", "target", "_serverName");
   setClassProperty(
       "com.dragonflow.StandardMonitor.ASPMonitor", "topazName", "MS Active Server Pages");
   setClassProperty(
       "com.dragonflow.StandardMonitor.ASPMonitor", "topazType", "Web Application Server");
   setClassProperty("com.dragonflow.StandardMonitor.ASPMonitor", "classType", "application");
   setClassProperty("com.dragonflow.StandardMonitor.ASPMonitor", "applicationType", "NTCounter");
   if (!Platform.isWindows()) {
     setClassProperty("com.dragonflow.StandardMonitor.ASPMonitor", "loadable", "false");
   }
 }
Пример #9
0
  public static Vector getTemplateList(String s) {
    Vector vector = new Vector();
    vector.addElement("");
    vector.addElement("none");
    String s1 = Platform.getRoot() + "/groups/" + TEMPLATES_FILE;
    if (s.length() > 0) {
      s = Portal.cleanPortalServerID(s);
      s1 = Portal.getPortalSiteViewRootPath(s) + "/groups/" + TEMPLATES_FILE;
    }
    try {
      Array array = FrameFile.readFromFile(s1);
      for (int i = 1; i < array.size(); i++) {
        HashMap hashmap = (HashMap) array.at(i);
        vector.addElement(TextUtils.getValue(hashmap, "__id"));
        vector.addElement(TextUtils.getValue(hashmap, "__name"));
      }

    } catch (IOException e) {
      /* empty */
    }
    return vector;
  }
 static {
   String s = (com.dragonflow.StandardMonitor.Exchange2k3MailboxMonitor.class).getName();
   pNotAccessedN = new StringProperty("_notaccessedN");
   pNotAccessedN.setDisplayText("Days since access", "For \"Mailboxes not accessed in N days\"");
   pNotAccessedN.setParameterOptions(true, 5, false);
   pTopSizeN = new StringProperty("_topsizeN");
   pTopSizeN.setDisplayText("N largest mailboxes", "For \"Top N mailboxes in size\"");
   pTopSizeN.setParameterOptions(true, 6, false);
   StringProperty astringproperty[] = {pNotAccessedN, pTopSizeN};
   addProperties(s, astringproperty);
   addClassElement(s, Rule.stringToClassifier("status != OK\terror"));
   addClassElement(s, Rule.stringToClassifier("always\tgood", true));
   setClassProperty(s, "description", "Monitors Exchange 2003 Mailboxes.");
   setClassProperty(s, "title", "Exchange 2003 Mailbox");
   setClassProperty(s, "class", "Exchange2k3MailboxMonitor");
   setClassProperty(s, "help", "Exch2k3MailboxMon.htm");
   setClassProperty(s, "target", "_server");
   setClassProperty(s, "topazName", "Exchange 2003 Mailbox");
   setClassProperty(s, "classType", "application");
   if (!Platform.isWindows() || !LUtils.isValidSSforXLicense(new Exchange2k3MailboxMonitor())) {
     setClassProperty(s, "loadable", "false");
   }
   setClassProperty(s, "addable", "false");
 }
Пример #11
0
  protected boolean update() {
    String s = getProperty(pMachineName);
    long l = 0L;
    long l1 = 0L;
    try {
      l = Long.parseLong(getProperty(pLastMeasurement));
      l1 = Long.parseLong(getProperty(pLastPageFaults));
    } catch (NumberFormatException numberformatexception) {
    }
    ArrayList array = null;
    if (monitorDebugLevel == 3) {
      array = new ArrayList();
    }
    long al[] = Platform.getMemoryFull(s, l1, l, this, array);
    long l2 = al[0];
    long l3 = al[2];
    long l4 = l3 - al[1];
    long l5 = al[3];
    long l6 = al[4];
    l1 = al[5];
    l = al[6];
    long l7 = al[7];
    String s1 = "" + l4 / 0x100000L;
    float f = -1F;
    if (l5 != -1L && l6 != 0L) {
      float f1 = (float) l6 / (float) l7;
      f = (float) l5 / f1;
      if ((double) f < 0.001D) {
        f = 0.0F;
      }
    }
    if (stillActive()) {
      synchronized (this) {
        setProperty(pLastPageFaults, l1);
        setProperty(pLastMeasurement, l);
        if (l2 == -1L) {
          setProperty(pPercentFull, "n/a");
          setProperty(pFreeSpace, "n/a");
          setProperty(pPageFaultsPerSecond, "n/a");
          setProperty(pMeasurement, 0);
          setProperty(pStateString, "no data");
          setProperty(pNoData, "n/a");
          if (monitorDebugLevel == 3 && array != null) {
            StringBuffer stringbuffer = new StringBuffer();
            for (int i = 0; i < array.size(); i++) {
              stringbuffer.append(array.get(i) + "\n");
            }

            LogManager.log(
                "Error", "MemoryMonitor: " + getFullID() + " failed, output:\n" + stringbuffer);
          }
        } else {
          setProperty(pPercentFull, l2);
          setProperty(pFreeSpace, l4 / 0x100000L);
          setProperty(pMeasurement, getMeasurement(pPercentFull));
          String s2 = l2 + "% used, " + s1 + "MB free";
          if (f == -1F) {
            setProperty(pPageFaultsPerSecond, "n/a");
          } else {
            setProperty(pPageFaultsPerSecond, f);
            s2 = s2 + ", " + TextUtils.floatToString(f, 2) + " pages/sec";
          }
          setProperty(pStateString, s2);
        }
      }
    }
    return true;
  }
Пример #12
0
  /** CAUTION: Decompiled by hand. */
  protected boolean update() {
    long l = Platform.timeMillis();
    int i = -1;
    String[] as = (new String[] {""});
    String s = getProperty(pExpression);
    long l1 = getPropertyAsLong(pMaxMeasurement);
    int j = getPropertyAsInteger(pCacheLife);
    boolean flag = j > 0;
    ArrayList array = new ArrayList();
    String s1 = "";

    try {
      String s2 = I18N.toDefaultEncoding(getProperty(pScript));
      String s3 = I18N.toDefaultEncoding(getProperty(pRemoteScript));
      String s4 = null;
      String s7 = I18N.toDefaultEncoding(getProperty(pLocalScriptLocation));
      if (s7.length() == 0) {
        s7 = "scripts";
      } else if (s7.indexOf("../") >= 0 || s7.indexOf("..\\") >= 0) {
        failMonitorRun(i, "Illegal Script Location contains ../ construct");
        return true;
      }

      s1 = getProperty(pMachineName);
      if (Machine.isNTSSH(s1) && s2.equals("USE COMMAND")) {
        failMonitorRun(i, "Can't use this option with remote NT ssh connection");
        return true;
      }

      if (Platform.isRemote(s1) && Machine.getMachine(s1) == null) {
        failMonitorRun(i, "Remote host unreachable");
        return true;
      }

      if (Platform.isNTRemote(s1) && !Machine.isNTSSH(s1)) {
        failMonitorRun(i, "NT host must be configured as NT ssh remote ");
        return true;
      }

      if (s3.equals("none") && s2.equals("USE COMMAND")) {
        failMonitorRun(i, "Need to specify a script");
        return true;
      }

      if (s3.length() != 0 && !s3.equals("none")) {
        try {
          s4 = getCommandFromLocalFile(s3);
          s4 = TextUtils.replaceParameters(s4, getParameters(), getReplacementChars());
        } catch (IOException ioexception) {
          LogManager.log("Error", " File load error " + ioexception.toString());
          setProperty(pNoData, "n/a");
        }
      } else {
        if (!Platform.isRemote(s1)) {
          String s8 = Platform.getRoot() + "/" + s7 + "/" + s2;
          File file = new File(s8);
          s4 = file.getAbsolutePath();
        } else {
          String s9 = "scripts" + Machine.getMachinePathSeparator(s1) + s2;
          OSAdapter osadapter = Machine.getAdapter(s1);
          if (osadapter != null) {
            CommandLine commandline = new CommandLine();
            String s11 = osadapter.getCommandSetting("fileExists", "changeDirectory");
            if (s11.length() > 0) {
              s4 = s11;
            } else {
              s4 = "/usr/bin/cd";
            }
            commandline.exec(s4, s1, Platform.getLock(s1));
          }
          RemoteFile remotefile = new RemoteFile(s1, s9);
          s4 = remotefile.getFullPath();
        }
        s4 = s4 + " " + getParameters();
        System.out.println("Script: " + s4);
      }
      LogManager.log("RunMonitor", "Script monitor command: " + s4 + ", machine: " + s1);
      String s10 = s1;
      if (s10.startsWith("\\\\")) {
        s10 = s10.substring(2);
      }
      Machine machine = Machine.getNTMachine(s10);
      int j1 = getPropertyAsInteger(pTimeout) * 1000;
      if (j1 < 0) {
        j1 = getSettingAsLong("_scriptMonitorTimeout", -1) * 1000;
      }
      String s12 = getScriptServerName(s1);
      String s14 =
          getProperty(pScript).equals("USE COMMAND")
              ? getProperty(pRemoteScript)
              : getProperty(pScript);
      ScriptMonitorCache scriptmonitorcache =
          new ScriptMonitorCache(s12, s14, getPropertyAsInteger(pCacheLife));
      if (!flag && alertDebug) {
        System.out.println("Caching is disabled.");
      }
      boolean flag1 = scriptmonitorcache.isFresh();
      if (flag && flag1 && scriptmonitorcache.getExitValue() == 0) {
        if (alertDebug) {
          System.out.println(
              "Caching is enabled, the cache life time is set to: "
                  + getPropertyAsInteger(pCacheLife));
        }
        if (alertDebug) {
          System.out.println(
              "The cache is still good, not exec'ing script, cache last modified on: "
                  + scriptmonitorcache.getLastModDate());
        }
        array = scriptmonitorcache.getOutput();
        i = scriptmonitorcache.getExitValue();
      } else if (machine != null && Machine.isNTSSH(s10)) {
        if (s4.indexOf("\\\\" + s10) > 0) {
          s4 = TextUtils.replaceString(s4, "\\\\" + s10, "");
        }
        s4 = "scripts\\" + s4.substring(s4.indexOf(s2));
        if (j1 > 0) {
          s4 = CommandLine.getExecSyncCmd(s10, s4, j1, true);
        }
        SSHCommandLine sshcommandline = new SSHCommandLine();
        array = sshcommandline.exec(s4, machine, false);
        i = sshcommandline.exitValue;
      } else {
        CommandLine commandline1 = new CommandLine();
        array = commandline1.exec(s4, s1, Platform.monitorLock, j1);
        i = commandline1.getExitValue();
      }
      if (flag && !flag1) {
        if (alertDebug) {
          System.out.println("Exec'd script and updating cache.");
        }
        scriptmonitorcache.update(i, array);
      }
      if (i < 0) {
        String s16 = "Failed to run script";
        if (i == Monitor.kURLTimeoutError) {
          s16 = "Script timed out";
        }
        failMonitorRun(i, s16);
        return true;
      }

      StringBuffer stringbuffer1 = new StringBuffer();
      String s17;
      Enumeration enumeration = (Enumeration) array.iterator();
      while (enumeration.hasMoreElements()) {
        s17 = (String) enumeration.nextElement();
        LogManager.log("RunMonitor", "Script monitor machine " + s1 + " output: " + s17);
        if (s17.startsWith(CommandLine.PERFEX_EXECSYNC_TIMEOUT)) {
          failMonitorRun(-1, "Error: Timeout");
          return true;
        }
        if (s17.indexOf("not found") > 0
            || s17.indexOf("Not Found") > 0
            || s17.indexOf("denied") > 0
            || s17.indexOf("Denied") > 0
            || s17.indexOf("cannot execute") > 0
            || s17.indexOf("such file or directory") > 0) {
          failMonitorRun(-1, s17);
          return true;
        }

        stringbuffer1.append(s17);
        stringbuffer1.append("\n");
        if (s.length() > 0 && !TextUtils.isRegularExpression(s) && s17.indexOf(s) != -1) {
          long l4 = TextUtils.findLong(s17, "", "");
          if (l4 != -1L) {
            as[0] = String.valueOf(l4);
          }
        }
      }

      if (TextUtils.isSubstituteExpression(s)) {
        s = TextUtils.substitute(s, this);
      }
      if (s.length() > 0 && TextUtils.isRegularExpression(s)) {
        String s18 = stringbuffer1.toString();
        Perl5Util perl5util = new Perl5Util();
        if (perl5util.match(s, s18)) {
          int i2 = perl5util.groups();
          if (i2 > 0) {
            if (i2 == 1) {
              as = new String[i2];
              as[0] = perl5util.group(0);
            } else {
              if (--i2 > maxNumberOfMatches) {
                i2 = maxNumberOfMatches;
              }
              as = new String[i2];
              for (int j2 = 0; j2 < as.length && j2 < maxNumberOfMatches; j2++) {
                as[j2] = perl5util.group(j2 + 1);
              }
            }
          }
        } else {
          failMonitorRun(-1, "Content Match Error");
          return true;
        }
      }
    } catch (Exception exception) {
      LogManager.log("RunMonitor", "Script monitor error: " + exception + " machine: " + s1);
      setProperty(pNoData, "n/a");
    }

    LogManager.log("RunMonitor", "Script monitor exit: " + i + " machine: " + s1);
    setProperty(pScriptOutput, "");
    if (as[0].trim().length() == 0) {
      as[0] = "n/a";
      long l2 = getSettingAsLong("_scriptMonitorLinesToSave", 25);
      String s5 = "";
      for (int k = 0; k < array.size() && (long) k < l2; k++) {
        s5 = s5 + array.get(k);
        s5 = s5 + "^";
      }

      s5 = s5.replace('\r', ' ');
      s5 = s5.replace('\n', '^');
      setProperty(pScriptOutput, s5);
    }
    long l3 = Platform.timeMillis() - l;
    String s6 = TextUtils.floatToString((float) l3 / 1000F, 2) + " sec";
    if (stillActive()) {
      synchronized (this) {
        for (int i1 = 0; i1 < as.length; i1++) {
          setProperty(pMatchValue[i1], as[i1]);
        }

        setProperty(pStatus, i);
        if (i != 0) {
          setProperty(pNoData, "n/a");
        }
        setProperty(pRoundTripTime, l3);
        setProperty(pMeasurement, getMeasurement(pRoundTripTime, l1));
        if (s.length() > 0) {
          HashMap hashmap = getLabels();
          StringBuffer stringbuffer = new StringBuffer();
          for (int k1 = 0; k1 < as.length; k1++) {
            String s13 = getNameFromIndex(k1);
            String s15 = (String) hashmap.get(s13);
            if (s15 == null) {
              s15 = s13;
            }
            stringbuffer.append(s15 + "=" + as[k1] + (k1 >= as.length - 1 ? "" : ","));
          }

          setProperty(pStateString, stringbuffer);
        } else {
          setProperty(pStateString, "exit: " + i + ", " + s6);
        }
      }
    }
    return true;
  }
Пример #13
0
 public int getPlatform() {
   return Platform.getLocalPlatform();
 }
Пример #14
0
 protected String getTemplateConfigFilePath() {
   return Platform.getRoot() + "/groups/" + TEMPLATES_FILE;
 }
Пример #15
0
  public static Vector getScriptList(String s, String s1, HTTPRequest httprequest) {
    Vector vector = new Vector();
    String s2 = s1;
    if (s2 == null || s2.length() == 0) {
      s2 = "scripts";
    }
    s = Machine.getFullMachineID(s, httprequest);
    if (Machine.isPortalMachineID(s)) {
      String s3 = Machine.getServerIDFromMachineID(s);
      PortalSiteView portalsiteview = (PortalSiteView) Portal.getPortal().getElement(s3);
      if (portalsiteview != null) {
        String s4 =
            "/SiteView/cgi/go.exe/SiteView?page=remoteOp&operation=scripts&machineID="
                + Machine.getMachineFromMachineID(s)
                + "&account=administrator";
        ArrayList array2 = portalsiteview.sendURLToRemoteSiteView(s4, null);
        for (int i1 = 0; i1 < array2.size(); i1++) {
          vector.addElement(array2.get(i1));
        }

      } else {
        LogManager.log("Error", "Could not find SiteView ID: " + s3);
      }
    } else if (Machine.isNTSSH(s)) {
      RemoteFile remotefile = new RemoteFile(s, "scripts");
      ArrayList array = remotefile.listFiles();
      for (int j = 0; j < array.size(); j++) {
        String s5 = I18N.toNullEncoding((String) array.get(j));
        if (!s5.endsWith(".txt")
            && !s5.endsWith("directory.bat")
            && (s5.endsWith(".bat")
                || s5.endsWith(".vbs")
                || s5.endsWith(".exe")
                || s5.endsWith(".pl")
                || s5.endsWith(".sh"))) {
          String as1[] = TextUtils.split(s5, " ");
          s5 = as1[as1.length - 1].trim();
          vector.addElement(s5);
          vector.addElement(s5);
        }
      }

    } else if (Platform.isCommandLineRemote(s)) {
      RemoteFile remotefile1 = new RemoteFile(s, "scripts");
      int i = Machine.getOS(s);
      ArrayList array1 = remotefile1.listFiles();
      for (int l = 0; l < array1.size(); l++) {
        String s7 = I18N.toNullEncoding((String) array1.get(l));
        if (!s7.endsWith(".txt") && (!Platform.isUnix(i) || !s7.startsWith("."))) {
          vector.addElement(s7);
          vector.addElement(s7);
        }
      }

    } else {
      File file = new File(Platform.getUsedDirectoryPath(s2, httprequest.getAccount()));
      String as[] = file.list();
      for (int k = 0; k < as.length; k++) {
        String s6 = I18N.toNullEncoding(as[k]);
        if (s6.endsWith(".txt") || Platform.isUnix() && s6.startsWith(".")) {
          continue;
        }
        File file1 = new File(file, as[k]);
        if (!file1.isDirectory()) {
          vector.addElement(s6);
          vector.addElement(s6);
        }
      }
    }
    return vector;
  }
Пример #16
0
  static {
    maxNumberOfMatches = 30;
    ArrayList arraylist = new ArrayList();
    pScript = new ScalarProperty("_script", "");
    if (Platform.isWindows()) {
      pScript.setDisplayText(
          "Script",
          "the script from the scripts directory to run (example: scriptTest.bat), or choose <a href=\"\\SiteView\\docs\\ScriptMon.htm#script\" TARGET=Help>USE COMMAND </a>for the command file below.");
    } else {
      pScript.setDisplayText(
          "Script",
          "the script from the scripts directory to run (example: scriptTest.sh),  or choose <a href=\"\\SiteView\\docs\\ScriptMon.htm#script\" TARGET=Help>USE COMMAND </a>for the command file below.");
    }
    pScript.setParameterOptions(true, 2, false);
    arraylist.add(pScript);
    pParameters = new StringProperty("_parameters", "");
    pParameters.setDisplayText(
        "Parameters",
        "additional parameters to pass to the script. Optionally, use a <a href=/SiteView/docs/regexp.htm>regular expression</a> to insert date and time variables into the parameters <br>(e.g s/$month$ $day$ $year$/)");
    pParameters.setParameterOptions(true, 3, false);
    arraylist.add(pParameters);
    pLocalScriptLocation = new StringProperty("_localScriptLocation", "scripts");
    pLocalScriptLocation.setParameterOptions(false, true, 4, false);
    arraylist.add(pLocalScriptLocation);
    pRemoteScript = new ScalarProperty("_remotescript", "none");
    pRemoteScript.setDisplayText(
        "USE COMMAND Script File",
        "The file that contains a command to be run on the remote UNIX machine.");
    pRemoteScript.setParameterOptions(true, 4, true);
    arraylist.add(pRemoteScript);
    pCacheLife = new NumericProperty("_cacheLife", "0", "seconds");
    pCacheLife.setDisplayText(
        "Cache Life",
        "The lifetime, in seconds, of the cache, each monitor run will check if the cache life has expired, if it has not then the cache data will be used, otherwise the script will be executed to update the cache.");
    pCacheLife.setParameterOptions(true, 5, true);
    arraylist.add(pCacheLife);
    pExpression = new StringProperty("_expression");
    pExpression.setDisplayText(
        "Match Expression",
        "optional Perl regular expression to match against the output of the script or the command from the command file, to extract values (example: /(\\d*) File.*([\\d,]*) bytes/).");
    pExpression.setParameterOptions(true, 6, true);
    arraylist.add(pExpression);
    pMaxMeasurement = new NumericProperty("_maxMeasurement", "0", "milleseconds");
    pMaxMeasurement.setDisplayText(
        "Maximum for Measurement",
        "optional value to specify as maximum for gauge display in milleseconds (example: if the runtime of the script is 4 seconds and this value is set at 8 seconds (8000ms) than the gauge will show at 50%");
    pMaxMeasurement.setParameterOptions(true, 7, true);
    arraylist.add(pMaxMeasurement);
    pValueLabels = new StringProperty("_valeLabels", "");
    pValueLabels.setDisplayText(
        "Match Value Labels",
        "Labels for the values matched on the script output, separated by a \",\"");
    pValueLabels.setParameterOptions(true, 3, true);
    arraylist.add(pValueLabels);
    pTimeout = new NumericProperty("_timeout", "-1", "seconds");
    pTimeout.setDisplayText(
        "Timeout",
        "The total time, in seconds, to wait for a successful script run. Default value is -1 (no timeout).");
    pTimeout.setParameterOptions(false, 2, true);
    arraylist.add(pTimeout);
    int i = 1;
    pRoundTripTime = new NumericProperty("roundTripTime", "0", "milliseconds");
    pRoundTripTime.setLabel("round trip time");
    pRoundTripTime.setStateOptions(i++);
    arraylist.add(pRoundTripTime);
    pStatus = new StringProperty("status");
    pStatus.setIsThreshold(true);
    arraylist.add(pStatus);
    pStatusLabel = new StringProperty("_statusLabel", "status");
    pStatusLabel.setParameterOptions(false, 3, true);
    arraylist.add(pStatusLabel);
    pScriptOutput = new StringProperty("scriptOutput");
    arraylist.add(pScriptOutput);
    HashMap hashmap = MasterConfig.getMasterConfig();
    if (hashmap != null) {
      int j = TextUtils.toInt(TextUtils.getValue(hashmap, "_maxNumScriptMatches"));
      if (j > 0) {
        maxNumberOfMatches = j;
      }
    }
    pMatchValue = new NumericProperty[maxNumberOfMatches];
    int k = TextUtils.toInt(TextUtils.getValue(hashmap, "_defaultPrecision"));
    for (int l = 0; l < pMatchValue.length; l++) {
      String s = getNameFromIndex(l);
      pMatchValue[l] = new NumericProperty(s);
      pMatchValue[l].setStateOptions(i++);
      pMatchValue[l].setIsThreshold(true);
      if (k > 0) {
        pMatchValue[l].defaultPrecision = k;
      }
      arraylist.add(pMatchValue[l]);
    }

    StringProperty astringproperty[] = new StringProperty[arraylist.size()];
    for (int i1 = 0; i1 < arraylist.size(); i1++) {
      astringproperty[i1] = (StringProperty) arraylist.get(i1);
    }

    String s1 = (COM.dragonflow.StandardMonitor.ScriptMonitor.class).getName();
    addProperties(s1, astringproperty);
    addClassElement(s1, Rule.stringToClassifier("status != 0\terror"));
    addClassElement(s1, Rule.stringToClassifier("status == 0\tgood"));
    setClassProperty(
        s1,
        "description",
        "Verifies that a script or batch file can be run. Can also be used to automatically run scripts.");
    setClassProperty(s1, "help", "ScriptMon.htm");
    setClassProperty(s1, "title", "Script");
    setClassProperty(s1, "class", "ScriptMonitor");
    setClassProperty(s1, "target", "_script");
    setClassProperty(s1, "classType", "advanced");
    setClassProperty(s1, "loadable", "true");
    setClassProperty(s1, "topazName", "Script");
    setClassProperty(s1, "topazType", "System Resources");
  }
Пример #17
0
 public void resetTemplateCache() {
   templateCache = null;
   templateCacheLastUpdate = Platform.timeMillis();
 }
Пример #18
0
 static {
   rootDir = Platform.getRoot() + File.pathSeparatorChar + "ems" + File.pathSeparatorChar;
 }
 static {
   path = Platform.getRoot() + File.separator + "templates.applications" + File.separator;
   addProperties(
       (COM.dragonflow.StandardMonitor.MediaPlayerMonitorBase.class).getName(),
       new StringProperty[0]);
 }
  protected boolean update() {
    if (Platform.isWindows()) {
      for (int i = 0; i < getStateValues().length; i++) {
        unsetProperty(getStateValues()[i]);
      }

      if ((getMediaTrace() & 4) != 0) {
        mediaDebug("MediaPlayerMonitorBase(): Entered");
      }
      Array array = new Array();
      String s = getMediaCommand();
      if ((getMediaTrace() & 4) != 0) {
        mediaDebug("getMediaCommand(): " + s);
      }
      CommandLine commandline = new CommandLine();
      array = commandline.exec(s);
      int j = commandline.getExitValue();
      if ((getMediaTrace() & 4) != 0) {
        mediaDebug("mediaCommand: " + s + ",getExitValue(): " + j);
      }
      for (Enumeration enumeration = array.elements();
          enumeration.hasMoreElements();
          mediaDebug("Results: " + enumeration.nextElement())) {}
      boolean flag = false;
      if (j == 0) {
        try {
          BufferedReader bufferedreader = new BufferedReader(new FileReader(mediaLog));
          do {
            String s1;
            if ((s1 = bufferedreader.readLine()) == null) {
              break;
            }
            if (parseRecord(s1)) {
              flag = true;
            }
          } while (true);
          if (flag) {
            String s3 = "URL: " + getProperty(getPMediaURL());
            Array array1 = getCounters();
            for (int l = 0; l < array1.size(); l++) {
              if (l == 0) {
                s3 = s3 + "&nbsp";
              }
              String s4 = prepLabel((String) array1.at(l));
              s3 = s3 + s4 + "&nbsp;" + getProperty(getStateValues()[l]);
              if (l < array1.size() - 1) {
                s3 = s3 + ", ";
              }
            }

            setProperty(pStateString, s3);
            setProperty(getPStatus(), "ok");
          }
        } catch (FileNotFoundException filenotfoundexception) {
          LogManager.log("Error", "Error Opening: " + mediaLog + " " + filenotfoundexception);
          setProperty(pStateString, "Error opening media log file: " + mediaLog);
          setProperty(getPStatus(), "Error");
        } catch (IOException ioexception) {
          LogManager.log("Error", "Error reading: " + mediaLog + " " + ioexception);
          setProperty(pStateString, "Error reading media log file: " + mediaLog);
          setProperty(getPStatus(), "Error");
        }
      }
      if (!flag) {
        String s2 = "";
        StringBuffer stringbuffer = new StringBuffer();
        String s5 = "";
        System.out.println("Error in monitor !");
        try {
          BufferedReader bufferedreader1 = new BufferedReader(new FileReader(mediaLog + "_"));
          do {
            String s6;
            if ((s6 = bufferedreader1.readLine()) == null) {
              break;
            }
            stringbuffer.append(s6);
            int k = s6.indexOf("Error:");
            if (k >= 0) {
              if (s2.length() > 0) {
                s2 = s2 + "<br>";
              }
              s2 = s2 + s6.substring(k + 6).trim();
            }
          } while (true);
        } catch (FileNotFoundException filenotfoundexception1) {
          s2 = "File Not Found Exception occurrred while reading error log file.";
        } catch (IOException ioexception1) {
          s2 = "I/O Exception occurred while reading error log file.";
        }
        if (s2.length() > 0) {
          setError(handleUpdateError(s2));
        } else {
          setError(stringbuffer.toString());
        }
      }
      File file = new File(mediaLog);
      if (file != null) {
        if ((getMediaTrace() & 2) != 0) {
          mediaDebug("Delete Temp File: " + mediaLog);
        }
        try {
          file.delete();
        } catch (SecurityException securityexception) {
          LogManager.log(
              "Error",
              "MediaPlayerMonitorBase Security Exception caught deleting temp file: " + mediaLog);
        }
      } else {
        LogManager.log("Error", "MediaPlayerMonitorBase Error deleting temp file: " + mediaLog);
      }
      file = new File(mediaLog + "_");
      if (file != null) {
        if ((getMediaTrace() & 2) != 0) {
          mediaDebug("Delete Temp File: " + mediaLog + "_");
        }
        try {
          file.delete();
        } catch (SecurityException securityexception1) {
          LogManager.log(
              "Error",
              "MediaPlayerMonitorBase Security Exception caught deleting temp file: " + mediaLog);
        }
      } else {
        LogManager.log(
            "Error", "MediaPlayerMonitorBase Error deleting temp file: " + mediaLog + "_");
      }
      if ((getMediaTrace() & 4) != 0) {
        mediaDebug("MediaPlayerMonitorBase(): Exited");
      }
      return true;
    } else {
      return false;
    }
  }