Class ProcessStat

java.lang.Object
oshi.driver.linux.proc.ProcessStat

public final class ProcessStat
extends java.lang.Object
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static class  ProcessStat.PidStat
    Enum corresponding to the fields in the output of /proc/[pid]/stat
  • Method Summary

    Modifier and Type Method Description
    static java.io.File[] getPidFiles()
    Gets an array of files in the /proc directory with only numeric digit filenames, corresponding to processes
    static Triplet<java.lang.String,​java.lang.Character,​java.util.Map<ProcessStat.PidStat,​java.lang.Long>> getPidStats​(int pid)
    Reads the statistics in /proc/[pid]/stat and returns the results.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getPidStats

      public static Triplet<java.lang.String,​java.lang.Character,​java.util.Map<ProcessStat.PidStat,​java.lang.Long>> getPidStats​(int pid)
      Reads the statistics in /proc/[pid]/stat and returns the results.
      Parameters:
      pid - The process ID for which to fetch stats
      Returns:
      A triplet containing the process name as the first element, a character representing the process state as the second element, and an EnumMap as the third element, where the numeric values in ProcessStat.PidStat are mapped to a Long value.

      If the process doesn't exist, returns null.

    • getPidFiles

      public static java.io.File[] getPidFiles()
      Gets an array of files in the /proc directory with only numeric digit filenames, corresponding to processes
      Returns:
      An array of File objects for the process files