Class CommandMonitor

java.lang.Object
services.moleculer.monitor.Monitor
services.moleculer.monitor.CommandMonitor

public class CommandMonitor extends Monitor
CPU monitor, which detects the current CPU usage via command line.
  • Field Details

    • command

      protected String command
  • Constructor Details

    • CommandMonitor

      public CommandMonitor()
    • CommandMonitor

      public CommandMonitor(String command)
  • Method Details

    • detectTotalCpuPercent

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

      protected long detectPID()
      Returns the PID of Java VM.
      Specified by:
      detectPID in class Monitor
      Returns:
      current Java VM's process ID
    • getCommand

      public String getCommand()
    • setCommand

      public void setCommand(String command)