Package oshi.driver.unix.solaris
Class PsInfo
- java.lang.Object
-
- oshi.driver.unix.solaris.PsInfo
-
@ThreadSafe public final class PsInfo extends java.lang.Object
Utility to query /proc/psinfo
-
-
Field Summary
Fields Modifier and Type Field Description private static SolarisLibc
LIBC
private static org.slf4j.Logger
LOG
private static long
PAGE_SIZE
-
Constructor Summary
Constructors Modifier Constructor Description private
PsInfo()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static long
conditionallyReadBufferFromStartOfPage(int fd, com.sun.jna.Memory buffer, com.sun.jna.platform.unix.LibCAPI.size_t bufSize, long bufStart, long addr)
Reads the page containing addr into buffer, unless the buffer already contains that page (as indicated by the bufStart address), in which case nothing is changed.private static long
getOffsetFromBuffer(com.sun.jna.Memory buffer, long offset, long increment)
static Pair<java.util.List<java.lang.String>,java.util.Map<java.lang.String,java.lang.String>>
queryArgsEnv(int pid, SolarisLibc.SolarisPsInfo psinfo)
Read the argument and environment strings from process address spacestatic Quartet<java.lang.Integer,java.lang.Long,java.lang.Long,java.lang.Byte>
queryArgsEnvAddrs(int pid, SolarisLibc.SolarisPsInfo psinfo)
Reads the pr_argc, pr_argv, pr_envp, and pr_dmodel fields from /proc/pid/psinfostatic SolarisLibc.SolarisLwpsInfo
queryLwpsInfo(int pid, int tid)
Reads /proc/pid/lwp/tid/lwpsinfo and returns data in a structurestatic SolarisLibc.SolarisPrUsage
queryPrUsage(int pid)
Reads /proc/pid/usage and returns data in a structurestatic SolarisLibc.SolarisPrUsage
queryPrUsage(int pid, int tid)
Reads /proc/pid/lwp/tid/usage and returns data in a structurestatic SolarisLibc.SolarisPsInfo
queryPsInfo(int pid)
Reads /proc/pid/psinfo and returns data in a structure
-
-
-
Field Detail
-
LOG
private static final org.slf4j.Logger LOG
-
LIBC
private static final SolarisLibc LIBC
-
PAGE_SIZE
private static final long PAGE_SIZE
-
-
Method Detail
-
queryPsInfo
public static SolarisLibc.SolarisPsInfo queryPsInfo(int pid)
Reads /proc/pid/psinfo and returns data in a structure- Parameters:
pid
- The process ID- Returns:
- A structure containing information for the requested process
-
queryLwpsInfo
public static SolarisLibc.SolarisLwpsInfo queryLwpsInfo(int pid, int tid)
Reads /proc/pid/lwp/tid/lwpsinfo and returns data in a structure- Parameters:
pid
- The process IDtid
- The thread ID (lwpid)- Returns:
- A structure containing information for the requested thread
-
queryPrUsage
public static SolarisLibc.SolarisPrUsage queryPrUsage(int pid)
Reads /proc/pid/usage and returns data in a structure- Parameters:
pid
- The process ID- Returns:
- A structure containing information for the requested process
-
queryPrUsage
public static SolarisLibc.SolarisPrUsage queryPrUsage(int pid, int tid)
Reads /proc/pid/lwp/tid/usage and returns data in a structure- Parameters:
pid
- The process IDtid
- The thread ID (lwpid)- Returns:
- A structure containing information for the requested thread
-
queryArgsEnvAddrs
public static Quartet<java.lang.Integer,java.lang.Long,java.lang.Long,java.lang.Byte> queryArgsEnvAddrs(int pid, SolarisLibc.SolarisPsInfo psinfo)
Reads the pr_argc, pr_argv, pr_envp, and pr_dmodel fields from /proc/pid/psinfo- Parameters:
pid
- The process IDpsinfo
- A populatedSolarisLibc.SolarisPsInfo
structure containing the offset pointers for these fields- Returns:
- A quartet containing the argc, argv, envp and dmodel values, or null if unable to read
-
queryArgsEnv
public static Pair<java.util.List<java.lang.String>,java.util.Map<java.lang.String,java.lang.String>> queryArgsEnv(int pid, SolarisLibc.SolarisPsInfo psinfo)
Read the argument and environment strings from process address space- Parameters:
pid
- the process idpsinfo
- A populatedSolarisLibc.SolarisPsInfo
structure containing the offset pointers for these fields- Returns:
- A pair containing a list of the arguments and a map of environment variables
-
conditionallyReadBufferFromStartOfPage
private static long conditionallyReadBufferFromStartOfPage(int fd, com.sun.jna.Memory buffer, com.sun.jna.platform.unix.LibCAPI.size_t bufSize, long bufStart, long addr)
Reads the page containing addr into buffer, unless the buffer already contains that page (as indicated by the bufStart address), in which case nothing is changed.- Parameters:
fd
- The file descriptor for the address spacebuffer
- An allocated buffer, possibly with data reread from bufStartbufSize
- The size of the bufferbufStart
- The start of data currently in bufStart, or 0 if uninitializedaddr
- THe address whose page to read into the buffer- Returns:
- The new starting pointer for the buffer
-
getOffsetFromBuffer
private static long getOffsetFromBuffer(com.sun.jna.Memory buffer, long offset, long increment)
-
-