Class ProcstatUtil
java.lang.Object
oshi.util.common.platform.unix.dragonflybsd.ProcstatUtil
Provides process information on DragonFlyBSD using /proc and fstat
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetCwd(int pid) Gets current working directory infogetCwdMap(int pid) Gets a map containing current working directory infostatic longgetOpenFiles(int pid) Gets open filesstatic StringparseCwdFromFstat(List<String> fstatLines) Parsesfstat -p <pid>output (DragonFlyBSD format) to find thewdrow and return the path column (the last whitespace-separated token of that row).static longparseOpenFiles(List<String> fstatLines) Counts open file descriptor rows infstat -p <pid>output (DragonFlyBSD format), excludingwd,root, andtextrows and the header line.
-
Method Details
-
getCwdMap
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
pidis a negative number, all processes are returned; otherwise the map may contain only a single element forpid
-
getCwd
Gets current working directory info- Parameters:
pid- a process ID- Returns:
- the current working directory for that process.
-
parseCwdFromFstat
Parsesfstat -p <pid>output (DragonFlyBSD format) to find thewdrow and return the path column (the last whitespace-separated token of that row).- Parameters:
fstatLines- lines returned byfstat -p <pid>- Returns:
- the working directory string, or empty if no
wdrow is found
-
getOpenFiles
public static long getOpenFiles(int pid) Gets open files- Parameters:
pid- The process ID- Returns:
- the number of open files.
-
parseOpenFiles
Counts open file descriptor rows infstat -p <pid>output (DragonFlyBSD format), excludingwd,root, andtextrows and the header line.- Parameters:
fstatLines- lines returned byfstat -p <pid>- Returns:
- the number of open files (counted rows minus 1 header), or 0 if none counted
-