bluepill-rb/bluepill

View on GitHub
lib/bluepill/process_conditions/cpu_usage.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Bluepill
  module ProcessConditions
    class CpuUsage < ProcessCondition
      def initialize(options = {})
        @below = options[:below]
      end

      def run(pid, include_children)
        # third col in the ps axu output
        System.cpu_usage(pid, include_children).to_f
      end

      def check(value)
        value < @below
      end
    end
  end
end