Пример #1
0
  public void init(PluginManager manager) throws PluginException {
    super.init(manager);

    final String prop = "sigar.mirror.procnet";
    final String enable = manager.getProperty(prop);
    getLog().debug(prop + "=" + enable);
    if (!"true".equals(enable)) {
      return;
    }

    // intended for use on systems with very large connection tables
    // where processing /proc/net/tcp may block or otherwise take much longer
    // than reading a plain 'ol text file
    // should only happen agent-side
    String dir = manager.getProperty(AgentConfig.PROP_TMPDIR[0]);
    ProcFileMirror mirror = null;
    final String[] procnet = {"/proc/net/tcp", "/proc/net/tcp6"};
    for (int i = 0; i < procnet.length; i++) {
      File file = new File(procnet[i]);
      if (!file.exists()) {
        continue;
      }
      if (mirror == null) {
        mirror = new ProcFileMirror(new Sigar(), dir);
      }

      try {
        mirror.add(file);
        getLog().debug("mirroring " + procnet[i]);
      } catch (SigarException e) {
        getLog().warn(e.getMessage());
      }
    }
    if (mirror != null) {
      FileWatcherThread.getInstance().add(mirror);
      FileWatcherThread.getInstance().doStart();
    }
  }
  public void init(PluginManager manager) throws PluginException {

    super.init(manager);
    this.props = manager.getProperties();
    this.defaultIp = this.props.getProperty("apache.listenAddress", "localhost");

    this.httpRange = new PortRange(this.props.getProperty("apache.http.ports"));

    this.httpsRange = new PortRange(this.props.getProperty("apache.https.ports"));

    // true == force discovery of mod_snmp based types when snmpd.conf does not exist
    this.discoverModSnmp = "true".equals(this.props.getProperty("apache.discover.mod_snmp"));

    // false == skip discovery of mod_status based types when snmpd.conf does not exist,
    // neither type will be reported.
    this.discoverModStatus =
        !"false".equals(this.props.getProperty("apache.discover.mod_status"))
            && !this.discoverModSnmp;
  }