Pārlūkot izejas kodu

AMBARI-6492. Flume: cleanup alert when none are found or single instance is running (ncole)

Nate Cole 11 gadi atpakaļ
vecāks
revīzija
4eb552e7d7

+ 11 - 7
ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/files/check_ambari_alerts.py

@@ -44,14 +44,14 @@ def main():
     exit(-1)
     exit(-1)
 
 
   if not os.path.exists(options.alert_file):
   if not os.path.exists(options.alert_file):
-    print "Alert file must exist"
-    exit(-1)
+    print "Status is unreported"
+    exit(3)
 
 
   try:
   try:
     with open(options.alert_file, 'r') as f:
     with open(options.alert_file, 'r') as f:
       data = json.load(f)
       data = json.load(f)
 
 
-      first = True
+      found = False
       buf = ''
       buf = ''
 
 
       for_hosts = data[options.alert_name]
       for_hosts = data[options.alert_name]
@@ -66,13 +66,17 @@ def main():
             print str(alert_text)
             print str(alert_text)
             exit(1)
             exit(1)
           else:
           else:
-            if not first:
+            if found:
               buf = buf + ', '
               buf = buf + ', '
             buf = buf + alert_text
             buf = buf + alert_text
-            first = False
+            found = True
 
 
-      print buf
-      exit(0)
+      if not found:
+        print "Status is not reported"
+        exit(3)
+      else:
+        print buf
+        exit(0)
       
       
   except Exception:
   except Exception:
     traceback.print_exc()
     traceback.print_exc()