-
- All Superinterfaces:
OperatingSystemMXBean,OperatingSystemMXBean,PlatformManagedObject
- All Known Subinterfaces:
UnixOperatingSystemMXBean
public interface OperatingSystemMXBean extends OperatingSystemMXBean
OpenJ9 platform management extension interface for the Operating System on which the Java Virtual Machine is running.
Usage example for theOperatingSystemMXBean... 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:Methods not fully supported on z/OS Method Return Value getCommittedVirtualMemorySize()-1OperatingSystemMXBean.getFreePhysicalMemorySize()-1getProcessPhysicalMemorySize()-1getProcessPrivateMemorySize()-1OperatingSystemMXBean.getSystemCpuLoad()-3.0(CpuLoadCalculationConstants.UNSUPPORTED_VALUE)- Since:
- 1.5
- See Also:
CpuLoadCalculationConstants
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description longgetCommittedVirtualMemorySize()Returns the amount of virtual memory used by the process in bytes.longgetFreeSwapSpaceSize()Returns the amount of free swap space in bytes.StringgetHardwareModel()Instantiates and returns an instance of aStringobject containing hardware model informationdoublegetProcessCpuLoad()Returns the recent CPU usage for the Java Virtual Machine process.longgetProcessCpuTime()Returns total amount of time the process has been scheduled or executed so far in both kernel and user modes.longgetProcessCpuTimeByNS()Deprecated, for removal: This API element is subject to removal in a future version.intgetProcessingCapacity()Returns the collective capacity of the virtual processors in the partition the VM is running in.longgetProcessPhysicalMemorySize()Returns the amount of physical memory being used by the process in bytes.longgetProcessPrivateMemorySize()Returns the amount of private memory used by the process in bytes.longgetProcessVirtualMemorySize()Deprecated, for removal: This API element is subject to removal in a future version.longgetTotalPhysicalMemory()Deprecated, for removal: This API element is subject to removal in a future version.longgetTotalSwapSpaceSize()Returns the total amount of swap space in bytes.booleanisHardwareEmulated()Identify whether the underlying hardware is being emulatedbooleanisProcessRunning(long pid)Indicates if the specified process is runningMemoryUsageretrieveMemoryUsage()Instantiates and returns an instance ofMemoryUsageobject that represents the current snapshot of Memory usage statistics.MemoryUsageretrieveMemoryUsage(MemoryUsage memObj)Returns an updatedMemoryUsageobject that represents the current snapshot of Memory usage statistics.ProcessorUsage[]retrieveProcessorUsage()Instantiates and returns an array ofProcessorUsageobjects that represent the current snapshot of individual Processor usage times.ProcessorUsage[]retrieveProcessorUsage(ProcessorUsage[] procArray)Returns an updated array ofProcessorUsageobjects that represent the current snapshot of individual Processor usage times.ProcessorUsageretrieveTotalProcessorUsage()Instantiate and return a newProcessorUsageobject that represents the current snapshot of Processor usage statistics.ProcessorUsageretrieveTotalProcessorUsage(ProcessorUsage procObj)Returns an updatedProcessorUsageobject that represents the current snapshot of Processor usage statistics.-
Methods declared in interface com.sun.management.OperatingSystemMXBean
getFreePhysicalMemorySize, getSystemCpuLoad, getTotalPhysicalMemorySize
-
Methods declared in interface java.lang.management.OperatingSystemMXBean
getArch, getAvailableProcessors, getName, getSystemLoadAverage, getVersion
-
Methods declared in interface java.lang.management.PlatformManagedObject
getObjectName
-
-
-
-
Method Detail
-
getTotalPhysicalMemory
@Deprecated(forRemoval=true, since="1.8") long getTotalPhysicalMemory()
Deprecated, for removal: This API element is subject to removal in a future version.Deprecated: use getTotalPhysicalMemorySize()- Returns:
- the total available physical memory on the system in bytes.
-
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:
getProcessCpuTimein interfaceOperatingSystemMXBean- Returns:
- process CPU time.
-
getProcessCpuTimeByNS
@Deprecated(forRemoval=true, since="1.8") long getProcessCpuTimeByNS()
Deprecated, for removal: This API element is subject to removal in a future version.Deprecated. Use getProcessCpuTime()
-
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:
getCommittedVirtualMemorySizein interfaceOperatingSystemMXBean- Returns:
- amount of virtual memory used by the process in bytes.
- Since:
- 1.8
-
getProcessVirtualMemorySize
@Deprecated(forRemoval=true, since="1.8") long getProcessVirtualMemorySize()
Deprecated, for removal: This API element is subject to removal in a future version.Deprecated. Use getCommittedVirtualMemorySize()
-
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:
getTotalSwapSpaceSizein 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:
getFreeSwapSpaceSizein 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:
getProcessCpuLoadin interfaceOperatingSystemMXBean- Returns:
- A value between 0 and 1.0, or a negative error code from
CpuLoadCalculationConstantsin case of an error. On the first call to the API,CpuLoadCalculationConstants.ERROR_VALUE (-1.0) shall be returned. - Since:
- 1.7
- See Also:
CpuLoadCalculationConstants
-
retrieveTotalProcessorUsage
ProcessorUsage retrieveTotalProcessorUsage(ProcessorUsage procObj) throws NullPointerException, ProcessorUsageRetrievalException
Returns an updatedProcessorUsageobject 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 providedProcessorUsageobject.- Returns:
- The updated
ProcessorUsageobject. - 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
ProcessorUsage retrieveTotalProcessorUsage() throws ProcessorUsageRetrievalException
Instantiate and return a newProcessorUsageobject 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
ProcessorUsageobject. - 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 ofProcessorUsageobjects that represent the current snapshot of individual Processor usage times.- Parameters:
procArray- User provided array ofProcessorUsageobjects.- Returns:
- The updated array of
ProcessorUsageobjects. - 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
ProcessorUsage[] retrieveProcessorUsage() throws ProcessorUsageRetrievalException
Instantiates and returns an array ofProcessorUsageobjects that represent the current snapshot of individual Processor usage times.- Returns:
- The new array of
ProcessorUsageobjects. - 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 updatedMemoryUsageobject that represents the current snapshot of Memory usage statistics.- Parameters:
memObj- User providedMemoryUsageobject.- Returns:
- The updated
MemoryUsageobject. - 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
MemoryUsage retrieveMemoryUsage() throws MemoryUsageRetrievalException
Instantiates and returns an instance ofMemoryUsageobject that represents the current snapshot of Memory usage statistics.- Returns:
- The new
MemoryUsageobject. - 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
String getHardwareModel() throws UnsupportedOperationException
Instantiates and returns an instance of aStringobject containing hardware model information- Returns:
- The new
Stringobject 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
boolean isHardwareEmulated() throws UnsupportedOperationExceptionIdentify 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
-
-