Class: Recmon::CommandSensor
- Defined in:
- lib/recmon/command-sensor.rb
Overview
Periodically execute a command and report success
Instance Method Summary collapse
-
#initialize(name, command, freq = 600) ⇒ CommandSensor
constructor
Create a new CommandSensor.
-
#sense ⇒ Object
Ensure user _recmon has permission to run the command.
Methods inherited from Sensor
Constructor Details
#initialize(name, command, freq = 600) ⇒ CommandSensor
Create a new CommandSensor. The name is descriptive and the command should be runnable by the _recmon user
11 12 13 14 |
# File 'lib/recmon/command-sensor.rb', line 11 def initialize(name, command, freq=600) super(name, freq) @command = command end |
Instance Method Details
#sense ⇒ Object
Ensure user _recmon has permission to run the command. An exit status of zero is required for success
18 19 20 21 22 23 |
# File 'lib/recmon/command-sensor.rb', line 18 def sense() `#{@command}` up = $?.exitstatus == 0 status = up ? "up" : "down" return("#{@name} status=#{status}") end |