Class: ActiveStatus
Overview
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.
Direct Known Subclasses
Constant Summary collapse
- OK =
Indicates everything is good with the service
'OK'
- WARNING =
Indicates a status of concern; not necessarily catastrophic
'WARNING'
- CRITICAL =
Indicates a serious failure or error
'CRITICAL'
- UNKNOWN =
Indicates that the status is unknown or can not be determined
'UNKNOWN'
- OK_EXIT_CODE =
UNIX/Linux exit code for Nagios OK
0
- WARNING_EXIT_CODE =
UNIX/Linux exit code for Nagios WARNING
1
- CRITICAL_EXIT_CODE =
UNIX/Linux exit code for Nagios CRITICAL
2
- UNKNOWN_EXIT_CODE =
UNIX/Linux exit code for Nagios UNKNOWN
3
Instance Attribute Summary
Attributes inherited from Status
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(status = nil, message = nil) ⇒ ActiveStatus
constructor
If status is not given, it will default to UNKNOWN.
- #status=(value) ⇒ Object
Methods inherited from Status
Constructor Details
#initialize(status = nil, message = nil) ⇒ ActiveStatus
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.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rnagios/active_status.rb', line 27 def initialize(status=nil, =nil) if status.nil? || (status != OK && status != WARNING && status != CRITICAL && status != UNKNOWN) @status = UNKNOWN else @status = status if !status.nil? end if .nil? @message = '<EMPTY>' else @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 |
Instance Method Details
#empty? ⇒ Boolean
71 72 73 |
# File 'lib/rnagios/active_status.rb', line 71 def empty? @status == UNKNOWN && (@message.nil? || @message.empty? || @message == '<EMPTY>') end |
#status=(value) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# 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 |