com.vaadin.open.
Class LinuxProcFileReader
- java.lang.Object
-
- com.vaadin.open.LinuxProcFileReader
-
public class LinuxProcFileReader extends Object
Linux /proc file reader. Read tick information for the system and the current process in order to provide stats on the cloud page about CPU utilization. Tick counts are monotonically increasing since boot. Find definitions of /proc file info here. http://man7.org/linux/man-pages/man5/proc.5.html
-
-
Constructor Summary
Constructors Constructor and Description LinuxProcFileReader()
Constructor.
-
Method Summary
All Methods Modifier and Type Method and Description long[][]
getCpuTicks()
Array of ticks.
int
getProcessCpusAllowed()
String
getProcessID()
int
getProcessNumOpenFds()
long
getProcessRss()
long
getProcessTotalTicks()
long
getSystemIdleTicks()
long
getSystemTotalTicks()
boolean
isWsl()
static int
numSetBitsHex(String s)
void
read()
Read and parse data from /proc/stat and /proc/<pid>/stat.
boolean
valid()
-
-
-
Method Detail
-
isWsl
public boolean isWsl()
Returns:
whether this java process is running in Windows Subsystem for Linux environment.
-
getSystemIdleTicks
public long getSystemIdleTicks()
Returns:
ticks the system was idle. in general: idle + busy == 100%
-
getSystemTotalTicks
public long getSystemTotalTicks()
Returns:
ticks the system was up.
-
getProcessTotalTicks
public long getProcessTotalTicks()
Returns:
ticks this process was running.
-
getCpuTicks
public long[][] getCpuTicks()
Array of ticks. [cpu number][tick type] tick types are: [0] user ticks [1] system ticks [2] other ticks (i/o) [3] idle ticks
Returns:
ticks array for each cpu of the system.
-
getProcessRss
public long getProcessRss()
Returns:
resident set size (RSS) of this process.
-
getProcessCpusAllowed
public int getProcessCpusAllowed()
Returns:
number of CPUs allowed by this process.
-
getProcessNumOpenFds
public int getProcessNumOpenFds()
Returns:
number of currently open fds of this process.
-
getProcessID
public String getProcessID()
Returns:
process id for this node as a String.
-
read
public void read()
Read and parse data from /proc/stat and /proc/<pid>/stat. If this doesn't work for some reason, the values will be -1.
-
valid
public boolean valid()
Returns:
true if all the values are ok to use; false otherwise.
-
numSetBitsHex
public static int numSetBitsHex(String s)
Returns:
number of set bits in hexadecimal string (chars must be 0-F)
-
-