diff options
author | Robin H. Johnson <robbat2@gentoo.org> | 2019-05-10 17:18:28 -0700 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2019-05-10 17:18:50 -0700 |
commit | 099c8c15727da8e49937ec08e3239e0d0f49290f (patch) | |
tree | 747ec7058bef874f8bccec4803b3fd0d85c5b3d2 /lib | |
parent | Remove defunct Google+ (diff) | |
download | infra-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>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/service_registry.rb | 11 |
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) && |