Interface OperatingSystemMXBean
- All Superinterfaces:
OperatingSystemMXBean
,OperatingSystemMXBean
,PlatformManagedObject
- All Known Subinterfaces:
UnixOperatingSystemMXBean
- All Known Implementing Classes:
ExtendedOperatingSystemMXBeanImpl
,UnixExtendedOperatingSystem
OpenJ9 platform management extension interface for the Operating System on which the Java Virtual Machine is running.
Usage example for the
OperatingSystemMXBean
...
com.ibm.lang.management.OperatingSystemMXBean osmxbean = null;
osmxbean = (com.ibm.lang.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
...
The following methods depend on certain information that is not available on z/OS; their return values are listed here:
Method | Return Value |
---|---|
getCommittedVirtualMemorySize() |
-1 |
OperatingSystemMXBean.getCpuLoad() |
-3.0 (CpuLoadCalculationConstants.UNSUPPORTED_VALUE ) |
OperatingSystemMXBean.getFreeMemorySize() |
-1 |
OperatingSystemMXBean.getFreePhysicalMemorySize() |
-1 |
getProcessPhysicalMemorySize() |
-1 |
getProcessPrivateMemorySize() |
-1 |
OperatingSystemMXBean.getSystemCpuLoad() |
-3.0 (CpuLoadCalculationConstants.UNSUPPORTED_VALUE ) |
- Since:
- 1.5
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionlong
Returns the amount of virtual memory used by the process in bytes.long
Returns the amount of free swap space in bytes.Instantiates and returns an instance of aString
object containing hardware model informationdouble
Returns the recent CPU usage for the Java Virtual Machine process.long
Returns total amount of time the process has been scheduled or executed so far in both kernel and user modes.int
Returns the collective capacity of the virtual processors in the partition the VM is running in.long
Returns the amount of physical memory being used by the process in bytes.long
Returns the amount of private memory used by the process in bytes.long
Returns the total amount of swap space in bytes.boolean
Identify whether the underlying hardware is being emulatedboolean
isProcessRunning
(long pid) Indicates if the specified process is runningInstantiates and returns an instance ofMemoryUsage
object that represents the current snapshot of Memory usage statistics.retrieveMemoryUsage
(MemoryUsage memObj) Returns an updatedMemoryUsage
object that represents the current snapshot of Memory usage statistics.Instantiates and returns an array ofProcessorUsage
objects that represent the current snapshot of individual Processor usage times.retrieveProcessorUsage
(ProcessorUsage[] procArray) Returns an updated array ofProcessorUsage
objects that represent the current snapshot of individual Processor usage times.Instantiate and return a newProcessorUsage
object that represents the current snapshot of Processor usage statistics.Returns an updatedProcessorUsage
object that represents the current snapshot of Processor usage statistics.Methods declared in interface com.sun.management.OperatingSystemMXBean
getCpuLoad, getFreeMemorySize, getFreePhysicalMemorySize, getSystemCpuLoad, getTotalMemorySize, getTotalPhysicalMemorySize
Methods declared in interface java.lang.management.OperatingSystemMXBean
getArch, getAvailableProcessors, getName, getSystemLoadAverage, getVersion
Methods declared in interface java.lang.management.PlatformManagedObject
getObjectName
-
Method Details
-
getProcessingCapacity
int getProcessingCapacity()Returns the collective capacity of the virtual processors in the partition the VM is running in. The value returned is in units of 1% of a physical processor's capacity, so a value of 100 is equal to 1 physical processor. In environments without such partitioning support, this call will return getAvailableProcessors() * 100.- Returns:
- the collective capacity of the virtual processors available to the VM.
-
getProcessCpuTime
long getProcessCpuTime()Returns total amount of time the process has been scheduled or executed so far in both kernel and user modes. Returns -1 if the value is unavailable on this platform or in the case of an error. Note that as of Java 8 SR5 the returned value is in 1 ns units, unless the system property com.ibm.lang.management.OperatingSystemMXBean.isCpuTime100ns is set to "true".- Specified by:
getProcessCpuTime
in interfaceOperatingSystemMXBean
- Returns:
- process CPU time.
-
getCommittedVirtualMemorySize
long getCommittedVirtualMemorySize()Returns the amount of virtual memory used by the process in bytes. Returns -1 if the value is unavailable on this platform or in the case of an error.- This information is not available on the z/OS platform.
- Specified by:
getCommittedVirtualMemorySize
in interfaceOperatingSystemMXBean
- Returns:
- amount of virtual memory used by the process in bytes.
- Since:
- 1.8
-
getProcessPrivateMemorySize
long getProcessPrivateMemorySize()Returns the amount of private memory used by the process in bytes. Returns -1 if the value is unavailable on this platform or in the case of an error.- This information is not available on the z/OS platform.
- Returns:
- amount of private memory used by the process in bytes.
-
getProcessPhysicalMemorySize
long getProcessPhysicalMemorySize()Returns the amount of physical memory being used by the process in bytes. Returns -1 if the value is unavailable on this platform or in the case of an error.- This information is not available on the AIX and z/OS platforms.
- Returns:
- amount of physical memory being used by the process in bytes.
-
getTotalSwapSpaceSize
long getTotalSwapSpaceSize()Returns the total amount of swap space in bytes.- Specified by:
getTotalSwapSpaceSize
in interfaceOperatingSystemMXBean
- Returns:
- the total amount of swap space in bytes.
- Since:
- 1.7
-
getFreeSwapSpaceSize
long getFreeSwapSpaceSize()Returns the amount of free swap space in bytes.- Specified by:
getFreeSwapSpaceSize
in interfaceOperatingSystemMXBean
- Returns:
- the amount of free swap space in bytes.
- Since:
- 1.7
-
getProcessCpuLoad
double getProcessCpuLoad()Returns the recent CPU usage for the Java Virtual Machine process. This value is a double in the [0.0,1.0] interval. A value of 0.0 means that none of the CPUs were running threads from the JVM process during the recent period of time observed, while a value of 1.0 means that all CPUs were actively running threads from the JVM 100% of the time during the recent period of time observed. Threads from the JVM include application threads as well as JVM internal threads. All values between 0.0 and 1.0 are possible. The first call to the method always returnsCpuLoadCalculationConstants
.ERROR_VALUE (-1.0), which marks the starting point. If the Java Virtual Machine's recent CPU usage is not available, the method returns a negative error code fromCpuLoadCalculationConstants
.- Specified by:
getProcessCpuLoad
in interfaceOperatingSystemMXBean
- Returns:
- A value between 0 and 1.0, or a negative error code from
CpuLoadCalculationConstants
in case of an error. On the first call to the API,CpuLoadCalculationConstants
.ERROR_VALUE (-1.0) shall be returned. - Since:
- 1.7
- See Also:
-
retrieveTotalProcessorUsage
ProcessorUsage retrieveTotalProcessorUsage(ProcessorUsage procObj) throws NullPointerException, ProcessorUsageRetrievalException Returns an updatedProcessorUsage
object that represents the current snapshot of Processor usage statistics. The snapshot is the aggregate of all Processors that are online at the time of sampling.- Parameters:
procObj
- User providedProcessorUsage
object.- Returns:
- The updated
ProcessorUsage
object. - Throws:
NullPointerException
- if a null reference is passed as parameter.ProcessorUsageRetrievalException
- if it failed obtaining Processor usage statistics.In case of an exception, the handler code might use toString() on the exception code to obtain a description of the exception.
- Since:
- 1.7.1
-
retrieveTotalProcessorUsage
Instantiate and return a newProcessorUsage
object that represents the current snapshot of Processor usage statistics. The snapshot is the aggregate of all Processors that are online at the time of sampling.- Returns:
- The new
ProcessorUsage
object. - Throws:
ProcessorUsageRetrievalException
- if it failed obtaining Processor usage statistics.In case of an exception, the handler code might use toString() on the exception code to obtain a description of the exception.
- Since:
- 1.7.1
-
retrieveProcessorUsage
ProcessorUsage[] retrieveProcessorUsage(ProcessorUsage[] procArray) throws NullPointerException, ProcessorUsageRetrievalException, IllegalArgumentException Returns an updated array ofProcessorUsage
objects that represent the current snapshot of individual Processor usage times.- Parameters:
procArray
- User provided array ofProcessorUsage
objects.- Returns:
- The updated array of
ProcessorUsage
objects. - Throws:
NullPointerException
- if a null reference is passed as parameter.ProcessorUsageRetrievalException
- if it failed obtaining Processor usage statistics.IllegalArgumentException
- if array provided has insufficient entries and there are more Processors to report on.In case of an exception, the handler code might use toString() on the exception code to obtain a description of the exception.
- Since:
- 1.7.1
-
retrieveProcessorUsage
Instantiates and returns an array ofProcessorUsage
objects that represent the current snapshot of individual Processor usage times.- Returns:
- The new array of
ProcessorUsage
objects. - Throws:
ProcessorUsageRetrievalException
- if it failed obtaining Processor usage statistics.In case of an exception, the handler code might use toString() on the exception code to obtain a description of the exception.
- Since:
- 1.7.1
-
retrieveMemoryUsage
MemoryUsage retrieveMemoryUsage(MemoryUsage memObj) throws NullPointerException, MemoryUsageRetrievalException Returns an updatedMemoryUsage
object that represents the current snapshot of Memory usage statistics.- Parameters:
memObj
- User providedMemoryUsage
object.- Returns:
- The updated
MemoryUsage
object. - Throws:
NullPointerException
- if a null reference is passed as parameter.MemoryUsageRetrievalException
- if it failed obtaining Memory usage statistics.In case of an exception, the handler code might use toString() on the exception code to obtain a description of the exception.
- Since:
- 1.7.1
-
retrieveMemoryUsage
Instantiates and returns an instance ofMemoryUsage
object that represents the current snapshot of Memory usage statistics.- Returns:
- The new
MemoryUsage
object. - Throws:
MemoryUsageRetrievalException
- if it failed obtaining Memory usage statistics.In case of an exception, the handler code might use toString() on the exception code to obtain a description of the exception.
- Since:
- 1.7.1
-
getHardwareModel
Instantiates and returns an instance of aString
object containing hardware model information- Returns:
- The new
String
object or NULL in case of an error. - Throws:
UnsupportedOperationException
- if the operation is not implemented on this platform. UnsupportedOperationException will also be thrown if the operation is implemented but it cannot be performed because the system does not satisfy all the requirements, for example, an OS service is not installed.- Since:
- 1.7
-
isHardwareEmulated
Identify whether the underlying hardware is being emulated- Returns:
- True if it is possible to identify that the hardware is being emulated. False otherwise.
- Throws:
UnsupportedOperationException
- if the emulated status cannot be determined- Since:
- 1.7
-
isProcessRunning
boolean isProcessRunning(long pid) Indicates if the specified process is running- Parameters:
pid
- Operating system process ID- Returns:
- True if the specified process exists
- Since:
- 1.8
-