Package org.elasticsearch.monitor.os
Class OsProbe
- java.lang.Object
-
- org.elasticsearch.monitor.os.OsProbe
-
public class OsProbe extends java.lang.ObjectTheOsProbeclass retrieves information about the physical and swap size of the machine memory, as well as the system load average and cpu load. In some exceptional cases, it's possible the underlying native method used bygetFreePhysicalMemorySize()andgetTotalPhysicalMemorySize()can return a negative value. Because of this, we prevent those methods from returning negative values, returning 0 instead. The OS can report a negative number in a number of cases: - Non-supported OSes (HP-UX, or AIX) - A failure of macOS to initialize host statistics - An OS that does not support the_SC_PHYS_PAGESor_SC_PAGE_SIZEflags for thesysconf()linux kernel call - An overflow of the product of_SC_PHYS_PAGESand_SC_PAGE_SIZE- An error case retrieving these values from a linux kernel - A non-standard libc implementation not implementing the required values For a more exhaustive explanation, see https://github.com/elastic/elasticsearch/pull/42725
-
-
Method Summary
Modifier and Type Method Description longgetFreePhysicalMemorySize()Returns the amount of free physical memory in bytes.longgetFreeSwapSpaceSize()Returns the amount of free swap space in bytes.static OsProbegetInstance()shortgetSystemCpuPercent()longgetTotalPhysicalMemorySize()Returns the total amount of physical memory in bytes.longgetTotalSwapSpaceSize()Returns the total amount of swap space in bytes.OsStatsosStats()
-
-
-
Method Detail
-
getFreePhysicalMemorySize
public long getFreePhysicalMemorySize()
Returns the amount of free physical memory in bytes.
-
getTotalPhysicalMemorySize
public long getTotalPhysicalMemorySize()
Returns the total amount of physical memory in bytes.
-
getFreeSwapSpaceSize
public long getFreeSwapSpaceSize()
Returns the amount of free swap space in bytes.
-
getTotalSwapSpaceSize
public long getTotalSwapSpaceSize()
Returns the total amount of swap space in bytes.
-
getSystemCpuPercent
public short getSystemCpuPercent()
-
getInstance
public static OsProbe getInstance()
-
osStats
public OsStats osStats()
-
-