Class Monitor

java.lang.Object
services.moleculer.monitor.Monitor
Direct Known Subclasses:
CommandMonitor, ConstantMonitor, JmxMonitor

public abstract class Monitor extends Object
Base superclass of all System Monitor implementations.
See Also:
  • Field Details

    • logger

      protected final org.slf4j.Logger logger
    • cacheTimeout

      protected long cacheTimeout
      CPU cache timeout in MILLISECONDS
    • cachedPID

      protected static AtomicLong cachedPID
      Cached process ID
    • cachedCPU

      protected static int cachedCPU
      Cached CPU usage
    • cpuDetectedAt

      protected static long cpuDetectedAt
      Timestamp of CPU detection
    • invalidMonitor

      protected static final AtomicBoolean invalidMonitor
  • Constructor Details

    • Monitor

      public Monitor()
  • Method Details

    • getTotalCpuPercent

      public int getTotalCpuPercent()
      Returns the cached system CPU usage, in percents, between 0 and 100.
      Returns:
      total CPU usage of the current OS
    • getPID

      public long getPID()
      Returns the cached PID of Java VM.
      Returns:
      current Java VM's process ID
    • detectTotalCpuPercent

      protected abstract int detectTotalCpuPercent() throws Exception
      Returns the system CPU usage, in percents, between 0 and 100.
      Returns:
      total CPU usage of the current OS
      Throws:
      Exception - any I/O or missing DLL exception
    • detectPID

      protected abstract long detectPID() throws Exception
      Returns the system CPU usage, in percents, between 0 and 100.
      Returns:
      total CPU usage of the current OS
      Throws:
      Exception - any I/O or missing DLL exception