Module: Icinga2::Converts
- Included in:
- Client
- Defined in:
- lib/icinga2/converts.rb
Overview
many convert functions
Class Method Summary collapse
-
.format_service(name) ⇒ String
reformat a service check name.
-
.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
86 87 88 89 |
# File 'lib/icinga2/converts.rb', line 86 def self.format_service( name ) service_map = name.split('!', 2) service_map.join( ' - ' ) end |
.state_to_color(state, is_host = false) ⇒ String
convert a Icinga2 state into a named color
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/icinga2/converts.rb', line 52 def self.state_to_color( state, is_host = false ) state = if( is_host == true ) case state when 0 'green' when 1 'red' else 'blue' end else case state when 0 'green' when 1 'yellow' when 2 'red' when 3 'purple' else 'blue' end end state end |
.state_to_string(state, is_host = false) ⇒ String
convert a Icinga2 state into a human readable state
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/icinga2/converts.rb', line 17 def self.state_to_string( state, is_host = false ) state = if( is_host == true ) case state when 0 'Up' when 1 'Down' else 'Undefined' end else case state when 0 'OK' when 1 'Warning' when 2 'Critical' when 3 'Unknown' else 'Undefined' end end state end |