Class: Recmon::ProcSensor
Overview
ProcSensor checks periodically to ensure a certain process is running
Instance Method Summary collapse
-
#initialize(name, pattern, freq = 60) ⇒ ProcSensor
constructor
Create a new ProcSensor.
-
#sense ⇒ Object
Called by Monitor.
Methods inherited from Sensor
Constructor Details
#initialize(name, pattern, freq = 60) ⇒ ProcSensor
Create a new ProcSensor. The pattern is a string as specified in pgrep(1).
9 10 11 12 |
# File 'lib/recmon/proc-sensor.rb', line 9 def initialize(name, pattern, freq=60) super(name, freq) @pattern = pattern end |
Instance Method Details
#sense ⇒ Object
Called by Monitor. This method executes pgrep(1) to check if one or more processes match
16 17 18 19 20 |
# File 'lib/recmon/proc-sensor.rb', line 16 def sense() `/usr/bin/pgrep -f "#{@pattern}"` status = $?.success? ? "running" : "stopped" return("proc=#{@name} status=#{status}") end |