Class Monitor
java.lang.Object
services.moleculer.monitor.Monitor
- Direct Known Subclasses:
CommandMonitor, ConstantMonitor, JmxMonitor
Base superclass of all System Monitor implementations.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static intCached CPU usageprotected static AtomicLongCached process IDprotected longCPU cache timeout in MILLISECONDSprotected static longTimestamp of CPU detectionprotected static final AtomicBooleanprotected final org.slf4j.Logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract longReturns the system CPU usage, in percents, between 0 and 100.protected abstract intReturns the system CPU usage, in percents, between 0 and 100.longgetPID()Returns the cached PID of Java VM.intReturns the cached system CPU usage, in percents, between 0 and 100.
-
Field Details
-
logger
protected final org.slf4j.Logger logger -
cacheTimeout
protected long cacheTimeoutCPU cache timeout in MILLISECONDS -
cachedPID
Cached process ID -
cachedCPU
protected static int cachedCPUCached CPU usage -
cpuDetectedAt
protected static long cpuDetectedAtTimestamp of CPU detection -
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
-
detectPID
-