summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2019-05-10 17:18:28 -0700
committerRobin H. Johnson <robbat2@gentoo.org>2019-05-10 17:18:50 -0700
commit099c8c15727da8e49937ec08e3239e0d0f49290f (patch)
tree747ec7058bef874f8bccec4803b3fd0d85c5b3d2
parentRemove defunct Google+ (diff)
downloadinfra-status-099c8c15727da8e49937ec08e3239e0d0f49290f.tar.gz
infra-status-099c8c15727da8e49937ec08e3239e0d0f49290f.tar.bz2
infra-status-099c8c15727da8e49937ec08e3239e0d0f49290f.zip
service_registry: easy helper for service/host_down
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-rw-r--r--lib/service_registry.rb11
1 files changed, 11 insertions, 0 deletions
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) &&