class ActiveStatus
Represents the status of an active check. Valid status strings for Nagios are OK
, WARNING
, CRITICAL
, and UNKNOWN
. UNIX/Linux exit codes are set automatically when you set the status attribute.
Constants
- CRITICAL
Indicates a serious failure or error
- CRITICAL_EXIT_CODE
UNIX/Linux exit code for Nagios
CRITICAL
- OK
Indicates everything is good with the service
- OK_EXIT_CODE
UNIX/Linux exit code for Nagios
OK
- UNKNOWN
Indicates that the status is unknown or can not be determined
- UNKNOWN_EXIT_CODE
UNIX/Linux exit code for Nagios
UNKNOWN
- WARNING
Indicates a status of concern; not necessarily catastrophic
- WARNING_EXIT_CODE
UNIX/Linux exit code for Nagios
WARNING
Public Class Methods
new(status=nil, message=nil)
click to toggle source
If status is not given, it will default to UNKNOWN
. If message is not given, it will default to <EMPTY>. UNIX/Linux exit codes are assigned automatically.
# File lib/rnagios/active_status.rb, line 27 def initialize(status=nil, message=nil) if status.nil? || (status != OK && status != WARNING && status != CRITICAL && status != UNKNOWN) @status = UNKNOWN else @status = status if !status.nil? end if message.nil? @message = '<EMPTY>' else @message = message end case @status when OK @exit_code = OK_EXIT_CODE when WARNING @exit_code = WARNING_EXIT_CODE when CRITICAL @exit_code = CRITICAL_EXIT_CODE when UNKNOWN @exit_code = UNKNOWN_EXIT_CODE end end
Public Instance Methods
empty?()
click to toggle source
# File lib/rnagios/active_status.rb, line 71 def empty? @status == UNKNOWN && (@message.nil? || @message.empty? || @message == '<EMPTY>') end
status=(value)
click to toggle source
# File lib/rnagios/active_status.rb, line 52 def status=(value) if value.nil? || (value != OK && value != WARNING && value != CRITICAL && value != UNKNOWN) @status = UNKNOWN else @status = value end case @status when OK @exit_code = OK_EXIT_CODE when WARNING @exit_code = WARNING_EXIT_CODE when CRITICAL @exit_code = CRITICAL_EXIT_CODE when UNKNOWN @exit_code = UNKNOWN_EXIT_CODE end end