Example #1
0
  @Override
  public String getValue() throws Exception {
    Sigar sigar = new Sigar();
    long value = 0;
    long[] pids = sigar.getProcList();

    for (long pid : pids) {
      ProcState state = null;

      try {
        state = sigar.getProcState(pid);
      } catch (Exception e) {
        // Process exited!
      }

      if (state != null) {
        if (getProc().equals("ALL") || state.getName().equals(getProc())) {
          value += requestValue(sigar, value, pid, state);
        }
      }
    }

    return "" + value;
  }