Module: Icinga2::Converts
- Included in:
- Client
- Defined in:
- lib/icinga2/converts.rb
Overview
many convert functions
Constant Summary collapse
- HOST_STATE_STRING =
%w[Up Down].freeze
- SERVICE_STATE_STRING =
%w[OK Warning Critical Unknown].freeze
- HOST_STATE_COLOR =
%w[green red].freeze
- SERVICE_STATE_COLOR =
%w[green yellow red purple].freeze
Class Method Summary collapse
-
.format_service(name) ⇒ String
reformat a service check name.
Instance Method Summary collapse
-
#state_to_color(state, is_host = false) ⇒ String
convert a Icinga2 state into a named color.
-
#state_to_string(state, is_host = false) ⇒ String
convert a Icinga2 state into a human readable state.
Class Method Details
.format_service(name) ⇒ String
reformat a service check name
51 52 53 54 |
# File 'lib/icinga2/converts.rb', line 51 def self.format_service( name ) service_map = name.split('!', 2) service_map.join( ' - ' ) end |
Instance Method Details
#state_to_color(state, is_host = false) ⇒ String
convert a Icinga2 state into a named color
38 39 40 41 42 43 |
# File 'lib/icinga2/converts.rb', line 38 def state_to_color( state, is_host = false ) result = SERVICE_STATE_COLOR[state] unless( is_host ) result = HOST_STATE_COLOR[state] if( is_host ) result = 'blue' if( result.nil? ) result end |
#state_to_string(state, is_host = false) ⇒ String
convert a Icinga2 state into a human readable state
24 25 26 27 28 29 |
# File 'lib/icinga2/converts.rb', line 24 def state_to_string( state, is_host = false ) result = SERVICE_STATE_STRING[state] unless( is_host ) result = HOST_STATE_STRING[state] if( is_host ) result = 'Undefined' if( result.nil? ) result end |