Class ProcstatUtil

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

@ThreadSafe public final class ProcstatUtil extends Object
Provides process information on DragonFlyBSD using /proc and fstat
  • 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
    • 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.
    • parseCwdFromFstat

      public static String parseCwdFromFstat(List<String> fstatLines)
      Parses fstat -p <pid> output (DragonFlyBSD format) to find the wd row and return the path column (the last whitespace-separated token of that row).
      Parameters:
      fstatLines - lines returned by fstat -p <pid>
      Returns:
      the working directory string, or empty if no wd 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> fstatLines)
      Counts open file descriptor rows in fstat -p <pid> output (DragonFlyBSD format), excluding wd, root, and text rows and the header line.
      Parameters:
      fstatLines - lines returned by fstat -p <pid>
      Returns:
      the number of open files (counted rows minus 1 header), or 0 if none counted