Class: OpennebulaProbe

Inherits:
Object
  • Object
show all
Defined in:
lib/probe/opennebula_probe.rb

Overview

OpennebulaProbe covers generic implementation of subprobes.

Attributes

  • logger - Logger connector.

  • message - Resulting message.

  • retval - Probe status constant.

  • endpoint - Server URI.

Options

  • opts - Hash with parsed command line arguments.

Examples

Instance is initialized from child class

Constant Summary collapse

OK_MSG =
'Remote resources successfully queried!'
WARN_MSG =
'Failed to query specified remote resources!'
CRIT_MSG =
'Failed to establish connection with the remote server!'
UNKWN_MSG =
'An exception or error occured!'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ OpennebulaProbe

Returns a new instance of OpennebulaProbe.



57
58
59
60
61
62
63
# File 'lib/probe/opennebula_probe.rb', line 57

def initialize(opts = {})
  @opts     = opts
  @retval   = UNKNOWN
  @logger   = nil
  @message  = "#{UNKWN_MSG}"
  @endpoint = "#{@opts.protocol.to_s}://#{@opts.hostname}:#{@opts.port.to_s}#{@opts.path}"
end

Instance Attribute Details

#logger=(value) ⇒ Object (writeonly)

Sets the attribute logger

Parameters:

  • value

    the value to set the attribute logger to.



55
56
57
# File 'lib/probe/opennebula_probe.rb', line 55

def logger=(value)
  @logger = value
end

#messageObject (readonly)

Returns the value of attribute message.



54
55
56
# File 'lib/probe/opennebula_probe.rb', line 54

def message
  @message
end

#retvalObject (readonly)

Returns the value of attribute retval.



54
55
56
# File 'lib/probe/opennebula_probe.rb', line 54

def retval
  @retval
end

Instance Method Details

#check_critObject



65
66
67
68
# File 'lib/probe/opennebula_probe.rb', line 65

def check_crit
  # overridden in child class
  true
end

#check_warnObject



70
71
72
73
# File 'lib/probe/opennebula_probe.rb', line 70

def check_warn
  # overridden in child class
  true
end

#crit?Boolean

Returns:

  • (Boolean)


75
76
77
78
79
80
# File 'lib/probe/opennebula_probe.rb', line 75

def crit?
  return false unless check_crit
  @retval  = CRITICAL
  @message = "CRITICAL: #{CRIT_MSG}"
  true
end

#runObject



89
90
91
92
93
94
95
96
# File 'lib/probe/opennebula_probe.rb', line 89

def run
  unless crit?
    unless warn?
      @retval  = OK
      @message = "#{OK_MSG}"
    end
  end
end

#warn?Boolean

Returns:

  • (Boolean)


82
83
84
85
86
87
# File 'lib/probe/opennebula_probe.rb', line 82

def warn?
  return false unless check_warn
  @retval  = WARNING
  @message = "WARNING: #{WARN_MSG}"
  true
end