Class: IcingaApi::Service
Constant Summary collapse
- TARGET =
"service"- CHECKS =
{ integer: %i( SERVICE_ID SERVICE_INSTANCE_ID SERVICE_OBJECT_ID SERVICE_CURRENT_CHECK_ATTEMPTS SERVICE_MAX_CHECK_ATTEMPTS SERVICE_STATE_COUNT SERVICE_OBJECT_COUNT ), float: %i( SERVICE_LATENCY SERVICE_EXECUTION_TIME ), boolean: %i( SERVICE_IS_ACTIVE SERVICE_NOTIFICATIONS_ENABLED SERVICE_FLAP_DETECTION_ENABLED SERVICE_PASSIVE_CHECKS_ENABLED SERVICE_EVENT_HANDLER_ENABLED SERVICE_ACTIVE_CHECKS_ENABLED SERVICE_RETAIN_STATUS_INFORMATION SERVICE_RETAIN_NONSTATUS_INFORMATION SERVICE_OBSESS_OVER_SERVICE SERVICE_FAILURE_PREDICTION_ENABLED SERVICE_PROCESS_PERFORMANCE_DATA SERVICE_HAS_BEEN_CHECKED SERVICE_IS_FLAPPING SERVICE_PROBLEM_HAS_BEEN_ACKNOWLEDGED SERVICE_SHOULD_BE_SCHEDULED SERVICE_IS_PENDING SERVICE_LAST_HARD_STATE ), string: %i( SERVICE_NAME SERVICE_DISPLAY_NAME SERVICE_NOTES SERVICE_OUTPUT SERVICE_LONG_OUTPUT SERVICE_ICON_IMAGE SERVICE_ICON_IMAGE_ALT SERVICE_NOTES_URL SERVICE_ACTION_URL ), time: %i( SERVICE_LAST_CHECK SERVICE_LAST_STATE_CHANGE SERVICE_NEXT_CHECK SERVICE_LAST_HARD_STATE_CHANGE SERVICE_LAST_NOTIFICATION SERVICE_STATUS_UPDATE_TIME ) }
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#service_filter ⇒ Object
readonly
Returns the value of attribute service_filter.
Attributes inherited from Request
Instance Method Summary collapse
- #critical? ⇒ Boolean
- #current_state ⇒ Object
- #fetch(method) ⇒ Object
-
#initialize(connection, host, name) ⇒ Service
constructor
A new instance of Service.
- #ok? ⇒ Boolean
- #perfdata ⇒ Object
- #unknown? ⇒ Boolean
- #warning? ⇒ Boolean
Constructor Details
#initialize(connection, host, name) ⇒ Service
Returns a new instance of Service.
71 72 73 74 75 76 |
# File 'lib/icinga_api/service.rb', line 71 def initialize(connection, host, name) @connection = connection @host = host @name = name @service_filter = and_filters(@host.host_filter, filter("SERVICE_NAME", "=", name)) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/icinga_api/service.rb', line 4 def name @name end |
#service_filter ⇒ Object (readonly)
Returns the value of attribute service_filter.
4 5 6 |
# File 'lib/icinga_api/service.rb', line 4 def service_filter @service_filter end |
Instance Method Details
#critical? ⇒ Boolean
115 116 117 |
# File 'lib/icinga_api/service.rb', line 115 def critical? current_state == :critical end |
#current_state ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/icinga_api/service.rb', line 90 def current_state rc = request(TARGET, @service_filter, ["SERVICE_CURRENT_STATE"]) case rc[:result][0][:SERVICE_CURRENT_STATE].to_i when 0 :ok when 1 :warning when 2 :critical when 4 :unknown end end |
#fetch(method) ⇒ Object
79 80 81 |
# File 'lib/icinga_api/service.rb', line 79 def fetch(method) string_request(TARGET, @service_filter, method) end |
#ok? ⇒ Boolean
105 106 107 |
# File 'lib/icinga_api/service.rb', line 105 def ok? current_state == :ok end |
#perfdata ⇒ Object
84 85 86 87 |
# File 'lib/icinga_api/service.rb', line 84 def perfdata rc = request(TARGET, @service_filter, [:SERVICE_PERFDATA]) # TODO: parsen end |
#unknown? ⇒ Boolean
120 121 122 |
# File 'lib/icinga_api/service.rb', line 120 def unknown? current_state == :unknown end |
#warning? ⇒ Boolean
110 111 112 |
# File 'lib/icinga_api/service.rb', line 110 def warning? current_state == :warning end |