Interface OperatingSystemMXBean

    • 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:
        getProcessCpuTime in interface OperatingSystemMXBean
        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:
        getCommittedVirtualMemorySize in interface OperatingSystemMXBean
        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:
        getTotalSwapSpaceSize in interface OperatingSystemMXBean
        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 interface OperatingSystemMXBean
        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 returns CpuLoadCalculationConstants.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 from CpuLoadCalculationConstants.
        Specified by:
        getProcessCpuLoad in interface OperatingSystemMXBean
        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:
        CpuLoadCalculationConstants
      • retrieveTotalProcessorUsage

        ProcessorUsage retrieveTotalProcessorUsage()
                                            throws ProcessorUsageRetrievalException
        Instantiate and return a new ProcessorUsage 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
      • retrieveMemoryUsage

        MemoryUsage retrieveMemoryUsage()
                                 throws MemoryUsageRetrievalException
        Instantiates and returns an instance of MemoryUsage 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

        String getHardwareModel()
                         throws UnsupportedOperationException
        Instantiates and returns an instance of a String 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

        boolean isHardwareEmulated()
                            throws UnsupportedOperationException
        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