Class: Recmon::SSHSensor
Overview
SSHSensor periodically checks that an SSH service is available
Instance Method Summary collapse
-
#initialize(name, user = "_recmon", port = 22, freq = 300) ⇒ SSHSensor
constructor
Create a new SSHSensor to periodically test SSH at the named host.
-
#sense ⇒ Object
Called by Monitor.
Methods inherited from Sensor
Constructor Details
#initialize(name, user = "_recmon", port = 22, freq = 300) ⇒ SSHSensor
Create a new SSHSensor to periodically test SSH at the named host
9 10 11 12 13 |
# File 'lib/recmon/ssh-sensor.rb', line 9 def initialize(name, user="_recmon", port=22, freq=300) super(name, freq) @user = user @port = port end |
Instance Method Details
#sense ⇒ Object
Called by Monitor. sense() attempts to log in to the host in batch mode so you MUST set up a private key authentication for this user or this sensor will generate false negatives.
18 19 20 21 22 23 |
# File 'lib/recmon/ssh-sensor.rb', line 18 def sense() `/usr/bin/ssh -p#{@port} -o "BatchMode yes" #{@user}@#{@name} pwd` up = $?.exitstatus == 0 status = up ? "up" : "down" return("SSH at host=#{@name} for user=#{@user} status=#{status}") end |