Class ProcstatUtil

java.lang.Object
oshi.util.common.platform.unix.freebsd.ProcstatUtil

@ThreadSafe public final class ProcstatUtil extends Object
Reads from procstat into a map
  • Method Details

    • getCwdMap

      public static Map<Integer,String> getCwdMap(int pid)
      Gets a map containing current working directory info
      Parameters:
      pid - a process ID, optional
      Returns:
      a map of process IDs to their current working directory. If pid is a negative number, all processes are returned; otherwise the map may contain only a single element for pid
    • parseCwdMap

      public static Map<Integer,String> parseCwdMap(List<String> procstatLines)
      Parses procstat -f output into a map of PID to current working directory by selecting rows whose third column is cwd.
      Parameters:
      procstatLines - lines returned by procstat -f
      Returns:
      a map of PID to working directory
    • getCwd

      public static String getCwd(int pid)
      Gets current working directory info
      Parameters:
      pid - a process ID
      Returns:
      the current working directory for that process.
    • parseCwd

      public static String parseCwd(List<String> procstatLines)
      Parses procstat -f <pid> output to return the working directory (the row whose third column is cwd).
      Parameters:
      procstatLines - lines returned by procstat -f <pid>
      Returns:
      the working directory string, or empty if no cwd row is found
    • getOpenFiles

      public static long getOpenFiles(int pid)
      Gets open files
      Parameters:
      pid - The process ID
      Returns:
      the number of open files.
    • parseOpenFiles

      public static long parseOpenFiles(List<String> procstatLines)
      Counts vnode and descriptor rows in procstat -f <pid> output, excluding rows whose fifth column is one of V, d, or -.
      Parameters:
      procstatLines - lines returned by procstat -f <pid>
      Returns:
      the number of open files