From 099c8c15727da8e49937ec08e3239e0d0f49290f Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Fri, 10 May 2019 17:18:28 -0700 Subject: service_registry: easy helper for service/host_down Signed-off-by: Robin H. Johnson --- lib/service_registry.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/service_registry.rb b/lib/service_registry.rb index 38aad87..c4296bf 100644 --- a/lib/service_registry.rb +++ b/lib/service_registry.rb @@ -27,6 +27,11 @@ module HelperMethods status_data['hosts'][host]['current_state'] == 0 end + def host_down?(host) + status_data['hosts'].key?(host) && + status_data['hosts'][host]['current_state'] == 1 + end + def host_flapping?(host) status_data['hosts'].key?(host) && status_data['hosts'][host]['is_flapping'] != 0 @@ -39,6 +44,12 @@ module HelperMethods status_data['services'][host][service]['current_state'] == 0 end + def service_down?(host, service) + status_data['services'].key?(host) && + status_data['services'][host].key?(service) && + status_data['services'][host][service]['current_state'] == 1 + end + def service_flapping?(host, service) status_data['services'].key?(host) && status_data['services'][host].key?(service) && -- cgit v1.2.3-65-gdbad