- 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.getFreeMemorySize() | -1 | 
| OperatingSystemMXBean.getFreePhysicalMemorySize() | -1 | 
| getProcessPhysicalMemorySize() | -1 | 
| getProcessPrivateMemorySize() | -1 | 
- Since:
- 1.5
- See Also:
- 
Method SummaryModifier and TypeMethodDescriptionlongReturns the amount of virtual memory used by the process in bytes.longReturns the amount of free swap space in bytes.Instantiates and returns an instance of aStringobject containing hardware model informationdoubleReturns the recent CPU usage for the Java Virtual Machine process.longReturns total amount of time the process has been scheduled or executed so far in both kernel and user modes.longDeprecated, for removal: This API element is subject to removal in a future version.intReturns the collective capacity of the virtual processors in the partition the VM is running in.longReturns the amount of physical memory being used by the process in bytes.longReturns the amount of private memory used by the process in bytes.longDeprecated, for removal: This API element is subject to removal in a future version.longDeprecated, for removal: This API element is subject to removal in a future version.longReturns the total amount of swap space in bytes.booleanIdentify whether the underlying hardware is being emulatedbooleanisProcessRunning(long pid) Indicates if the specified process is runningInstantiates and returns an instance ofMemoryUsageobject that represents the current snapshot of Memory usage statistics.retrieveMemoryUsage(MemoryUsage memObj) Returns an updatedMemoryUsageobject that represents the current snapshot of Memory usage statistics.Instantiates and returns an array ofProcessorUsageobjects that represent the current snapshot of individual Processor usage times.retrieveProcessorUsage(ProcessorUsage[] procArray) Returns an updated array ofProcessorUsageobjects that represent the current snapshot of individual Processor usage times.Instantiate and return a newProcessorUsageobject that represents the current snapshot of Processor usage statistics.Returns an updatedProcessorUsageobject that represents the current snapshot of Processor usage statistics.Methods declared in interface com.sun.management.OperatingSystemMXBeangetCpuLoad, getFreeMemorySize, getFreePhysicalMemorySize, getSystemCpuLoad, getTotalMemorySize, getTotalPhysicalMemorySizeMethods declared in interface java.lang.management.OperatingSystemMXBeangetArch, getAvailableProcessors, getName, getSystemLoadAverage, getVersionMethods declared in interface java.lang.management.PlatformManagedObjectgetObjectName
- 
Method Details- 
getTotalPhysicalMemoryDeprecated, for removal: This API element is subject to removal in a future version.Deprecated: use getTotalMemorySize()- Returns:
- the total available physical memory on the system in bytes.
 
- 
getProcessingCapacityint 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.
 
- 
getProcessCpuTimelong 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 interface- OperatingSystemMXBean
- Returns:
- process CPU time.
 
- 
getProcessCpuTimeByNSDeprecated, for removal: This API element is subject to removal in a future version.Deprecated. Use getProcessCpuTime()
- 
getCommittedVirtualMemorySizelong 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 interface- OperatingSystemMXBean
- Returns:
- amount of virtual memory used by the process in bytes.
- Since:
- 1.8
 
- 
getProcessVirtualMemorySizeDeprecated, for removal: This API element is subject to removal in a future version.Deprecated. Use getCommittedVirtualMemorySize()
- 
getProcessPrivateMemorySizelong 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.
 
- 
getProcessPhysicalMemorySizelong 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.
 
- 
getTotalSwapSpaceSizelong getTotalSwapSpaceSize()Returns the total amount of swap space in bytes.- Specified by:
- getTotalSwapSpaceSizein interface- OperatingSystemMXBean
- Returns:
- the total amount of swap space in bytes.
- Since:
- 1.7
 
- 
getFreeSwapSpaceSizelong getFreeSwapSpaceSize()Returns the amount of free swap space in bytes.- Specified by:
- getFreeSwapSpaceSizein interface- OperatingSystemMXBean
- Returns:
- the amount of free swap space in bytes.
- Since:
- 1.7
 
- 
getProcessCpuLoaddouble 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 interface- OperatingSystemMXBean
- 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:
 
- 
retrieveTotalProcessorUsageProcessorUsage 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 provided- ProcessorUsageobject.
- 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
 
- 
retrieveTotalProcessorUsageInstantiate 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
 
- 
retrieveProcessorUsageProcessorUsage[] 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 of- ProcessorUsageobjects.
- 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
 
- 
retrieveProcessorUsageInstantiates 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
 
- 
retrieveMemoryUsageMemoryUsage retrieveMemoryUsage(MemoryUsage memObj) throws NullPointerException, MemoryUsageRetrievalException Returns an updatedMemoryUsageobject that represents the current snapshot of Memory usage statistics.- Parameters:
- memObj- User provided- MemoryUsageobject.
- 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
 
- 
retrieveMemoryUsageInstantiates 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
 
- 
getHardwareModelInstantiates 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
 
- 
isHardwareEmulatedIdentify 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
 
- 
isProcessRunningboolean 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
 
 
-