Class: Pandur::Check

Inherits:
Object
  • Object
show all
Includes:
Config
Defined in:
lib/pandur/check.rb

Instance Method Summary collapse

Methods included from Config

#config, #load_config, #logger

Constructor Details

#initialize(target) ⇒ Check

Returns a new instance of Check.



5
6
7
# File 'lib/pandur/check.rb', line 5

def initialize(target)
  @config = target
end

Instance Method Details

#check(ssh) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/pandur/check.rb', line 9

def check(ssh)
  logger.debug("Checking #{@config['name']}")
  if @config['pid_file']
    print "Checking #{@config['name']}: "
    escaped_pid_file = @config['pid_file'].gsub('\'', '\\\'')
    if(ssh_exec!(ssh, "test -r '#{escaped_pid_file}' && test -n '`ps -ef | grep -v grep | grep \`cat '#{escaped_pid_file}'\``'")[2] > 0)
      puts "FAIL"
    else
      puts "OK"
    end
  else
    logger.debug("cannot check #{@config.inspect}")
  end
end