summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Legler <alex@a3li.li>2014-05-12 17:00:01 +0200
committerAlex Legler <alex@a3li.li>2014-05-12 17:00:01 +0200
commit45d9d907f809c246d635c09b95635282a3dd5140 (patch)
treea0f8e3e09c2e396ac2dcb6103f17864c7f0b23de /lib
parentBe more resilient to status.json update failures (diff)
downloadinfra-status-45d9d907f809c246d635c09b95635282a3dd5140.tar.gz
infra-status-45d9d907f809c246d635c09b95635282a3dd5140.tar.bz2
infra-status-45d9d907f809c246d635c09b95635282a3dd5140.zip
Return NA when a service has no data for a given host.
Diffstat (limited to 'lib')
-rw-r--r--lib/service_registry.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/service_registry.rb b/lib/service_registry.rb
index e374f1f..c6d208a 100644
--- a/lib/service_registry.rb
+++ b/lib/service_registry.rb
@@ -7,6 +7,7 @@ module State
UP=1
DOWN=2
WARNING=3
+ NA=0
end
module HelperMethods
@@ -44,6 +45,10 @@ module HelperMethods
status_data['services'][host][service]['is_flapping'] != 0
end
+ def has_service?(host, service)
+ status_data['services'][host].has_key?(service)
+ end
+
def default(host, service = nil)
if service == nil
if host_flapping? host
@@ -54,6 +59,8 @@ module HelperMethods
State::DOWN
end
else
+ return State::NA unless has_service? host, service
+
if service_flapping? host, service
State::WARNING
elsif service_up? host, service