Class CpuUsageResolver

java.lang.Object
eu.cloudnetservice.common.resource.CpuUsageResolver

public final class CpuUsageResolver extends Object
A utility class to resolve the usage of the host system CPU.
Since:
4.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final OperatingSystemMXBean
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static @org.jetbrains.annotations.Range(from=-1L, to=100L) double
    Reads the process cpu usage for the current jvm process and converts the returned value into a percentage.
    static @org.jetbrains.annotations.Range(from=-1L, to=100L) double
    Reads the current system cpu usage and converts the returned value into a percentage.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • CpuUsageResolver

      private CpuUsageResolver()
  • Method Details

    • systemCpuLoad

      public static @org.jetbrains.annotations.Range(from=-1L, to=100L) double systemCpuLoad()
      Reads the current system cpu usage and converts the returned value into a percentage. Note: in case that the value is not available, this method returns -1.
      Returns:
      the current system cpu load formatted to a percentage or -1 if not available.
    • processCpuLoad

      public static @org.jetbrains.annotations.Range(from=-1L, to=100L) double processCpuLoad()
      Reads the process cpu usage for the current jvm process and converts the returned value into a percentage. Note: in case that the value is not available, this method returns -1.
      Returns:
      the current process cpu load formatted to a percentage or -1 if not available.