Class: CheckFromFile::Check

Inherits:
Nagios::Plugin
  • Object
show all
Defined in:
lib/check_from_file/check.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Check

Returns a new instance of Check.



6
7
8
# File 'lib/check_from_file/check.rb', line 6

def initialize(options)
  @options = options
end

Instance Method Details

#checkObject



25
26
27
28
29
# File 'lib/check_from_file/check.rb', line 25

def check
  @return = File.read(@options[:return]).to_i
  @stdout = File.read(@options[:stdout])
  @stderr = File.read(@options[:stderr])
end

#critical?Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
# File 'lib/check_from_file/check.rb', line 10

def critical?
  unless @return == 0
    @error = true
    return false
  end
end

#messageObject



31
32
33
34
35
36
37
38
39
# File 'lib/check_from_file/check.rb', line 31

def message
  ret = "Command: #{@options[:command]} returned "
  if @error
    ret << "#{@return}, STDOUT: #{@stdout}, STDERR: #{@stderr}"
  else
    ret << "successfully"
  end
  ret
end

#ok?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/check_from_file/check.rb', line 21

def ok?
  true
end

#warning?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/check_from_file/check.rb', line 17

def warning?
  false # We don't support a warning state, just critical or ok
end