Package oshi.driver.linux.proc
Class ProcessStat
java.lang.Object
oshi.driver.linux.proc.ProcessStat
@ThreadSafe public final class ProcessStat extends java.lang.Object
Utility to read process statistics from
/proc/[pid]/stat-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classProcessStat.PidStatEnum corresponding to the fields in the output of/proc/[pid]/stat -
Field Summary
Fields Modifier and Type Field Description static intPROC_PID_STAT_LENGTHConstant defining the number of integer values in/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 processesstatic Triplet<java.lang.String,java.lang.Character,java.util.Map<ProcessStat.PidStat,java.lang.Long>>getPidStats(int pid)Reads the statistics in/proc/[pid]/statand returns the results.
-
Field Details
-
PROC_PID_STAT_LENGTH
public static final int PROC_PID_STAT_LENGTHConstant defining the number of integer values in/proc/pid/stat. 2.6 Kernel has 44 elements, 3.3 has 47, and 3.5 has 52.
-
-
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]/statand 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.PidStatare mapped to aLongvalue.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
-