commit:     45d9d907f809c246d635c09b95635282a3dd5140
Author:     Alex Legler <alex <AT> a3li <DOT> li>
AuthorDate: Mon May 12 15:00:01 2014 +0000
Commit:     Alex Legler <a3li <AT> gentoo <DOT> org>
CommitDate: Mon May 12 15:00:01 2014 +0000
URL:        
http://git.overlays.gentoo.org/gitweb/?p=proj/infra-status.git;a=commit;h=45d9d907

Return NA when a service has no data for a given host.

---
 lib/service_registry.rb | 7 +++++++
 1 file changed, 7 insertions(+)

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

Reply via email to