Class 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 Detail

      • LinuxProcFileReader

        public LinuxProcFileReader()
        Constructor.
    • 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)