Beispiel #1
0
  public ConfigSchema getConfigSchema(TypeInfo info, ConfigResponse config) {

    SchemaBuilder schema = new SchemaBuilder(config);
    log.debug("[getConfigSchema] info=" + info);
    switch (info.getType()) {
      case TypeInfo.TYPE_PLATFORM:
        // XXX does not work
        // schema.add(PROP_ENABLE_USER_AI,
        //           "Enable autodiscovery of user services",
        //           false);
        break;
      case TypeInfo.TYPE_SERVICE:
        if (info.isService(FS_NAME)) {
          schema.add(PROP_FS, "File System Mount", "/");
        } else if (info.isService(PHYSICAL_DISK_NAME)) {
          schema.add("name", "Instace Name", "");
        } else if (info.isService(FILE_NAME)) {
          schema.add(PROP_PATH, "Path to File", "../../log/agent.log");
        } else if (info.isService(DIR_NAME) || info.isService(DIR_TREE_NAME)) {
          schema.add(PROP_PATH, "Path to Directory", "data");
        } else if (info.isService(NETIF_NAME)) {
          schema.add(PROP_NETIF, "Network Interface", "eth0");
        } else if (info.getName().equals(CPU_NAME)) {
          schema.add(PROP_CPU, "CPU", "0");
        } else if (info.getName().equals(PROCESS_NAME)) {
          schema.add(SystemMeasurementPlugin.PTQL_CONFIG, "Process Query", "State.Name.eq=java");
        } else if (info.getName().equals(MPROCESS_NAME)) {
          schema.add(
              SystemMeasurementPlugin.PTQL_CONFIG, "Multi Process Query", "State.Name.eq=httpd");
        } else if (info.getName().equals(HYPERV_NETWORK_INTERFACE)) {
          schema.add(PROP_HYPERV_NETWORK_INTERFACE, HYPERV_NETWORK_INTERFACE + " Name", "/");
        } else if (info.getName().equals(HYPERV_PHYSICAL_DISK)) {
          schema.add(PROP_HYPERV_PHYSICAL_DISK, HYPERV_PHYSICAL_DISK + " Name", "/");
        } else if (info.getName().equals(HYPERV_LOGICAL_PROCESSOR)) {
          schema.add(PROP_HYPERV_LOGICAL_PROCESSOR, HYPERV_LOGICAL_PROCESSOR + " Name", "/");
        } else if (info.getName().equals(SVC_NAME)) {
          schema.add(PROP_SVC, SVC_NAME + " Name", "");
        } else if (info.getName().equals(SCRIPT_NAME)) {
          schema.add("prefix", "Prefix arguments to script", "").setOptional(true);
          schema.add(PROP_PATH, "Script Name", "/path/to/script");
          schema.add(ExecutableProcess.PROP_ARGS, "Script Arguments", "").setOptional(true);
          schema.add(ExecutableProcess.PROP_TIMEOUT, "Script Timeout (in seconds)", 120);
        }
        break;
    }

    return schema.getSchema();
  }
Beispiel #2
0
  public GenericPlugin getPlugin(String type, TypeInfo info) {
    if (type.equals(ProductPlugin.TYPE_MEASUREMENT)) {
      if (info.getName().equals(SVC_NAME)) {
        return new Win32MeasurementPlugin();
      }

      if (info.getName().equals(HYPERV_NETWORK_INTERFACE)) {
        return new HyperVMeasurementPlugin();
      }
      if (info.getName().equals(HYPERV_PHYSICAL_DISK)) {

        return new HyperVMeasurementPlugin();
      }
      if (info.getName().equals(HYPERV_MEMORY)) {
        return new Win32MeasurementPlugin();
      }
      if (info.getName().equals(HYPERV_LOGICAL_PROCESSOR)) {
        return new HyperVMeasurementPlugin();
      }
      if ((info.getType() == TypeInfo.TYPE_SERVER) && ((ServerTypeInfo) info).isVirtual()) {
        // virtual server, no metrics.
        return null;
      }
      if (info.getName().equals(SCRIPT_NAME)) {
        return new ExecutableMeasurementPlugin();
      } else {
        return new SystemMeasurementPlugin();
      }
    } else if (type.equals(ProductPlugin.TYPE_AUTOINVENTORY)) {
      switch (info.getType()) {
        case TypeInfo.TYPE_PLATFORM:
          return new SigarPlatformDetector(this.hasPlatformControlActions());
        case TypeInfo.TYPE_SERVER:
          if (info.getName().equals(FILE_SERVER_NAME)) {
            return new FileSystemDetector();
          } else if (info.getName().equals(NETWORK_SERVER_NAME)) {
            return new NetifDetector();
          } else if (info.getName().equals(PROCESS_SERVER_NAME)) {
            return new ProcessorDetector();
          } else if (info.getName().equals(WINDOWS_SERVER_NAME)) {
            return new WindowsDetector();
          } else if (info.getName().equals(HYPERV_SERVER_NAME)) {
            return new HypervDetector();
          }
      }
    } else if (type.equals(ProductPlugin.TYPE_CONTROL)) {
      if (info.isService(FILE_NAME)) {
        return new FileControlPlugin();
      } else if (info.getName().equals(SVC_NAME)) {
        return new Win32ControlPlugin();
      } else if (info.getName().equals(PROCESS_NAME)) {
        return new ProcessControlPlugin();
      }
    } else if (type.equals(ProductPlugin.TYPE_CONFIG_TRACK)) {
      if ((info.getType() == TypeInfo.TYPE_PLATFORM) || info.getName().equals(PROCESS_NAME)) {
        return new ConfigFileTrackPlugin();
      }
    } else if (type.equals(ProductPlugin.TYPE_LOG_TRACK)) {
      if (info.getType() == TypeInfo.TYPE_PLATFORM) {
        if (info.isWin32Platform()) {
          return new WindowsLogTrackPlugin();
        } else {
          return new UnixLogTrackPlugin();
        }
      } else if (info.getName().equals(SVC_NAME)) {
        return new Win32EventLogTrackPlugin();
      } else if (info.isService(FILE_NAME)) {
        return new FileServiceLogPlugin();
      } else if (info.getName().equals(PROCESS_NAME)) {
        return new LogFileTailPlugin();
      } else if (info.getName().equals(SCRIPT_NAME) || info.isService(FS_NAME)) {
        return new LogTrackPlugin();
      }
    } else if (type.equals(ProductPlugin.TYPE_LIVE_DATA)) {
      if (info.getType() == TypeInfo.TYPE_PLATFORM) {
        return new SystemLiveDataPlugin();
      }
    }

    return null;
  }