Parcourir la source

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

Nate Cole il y a 11 ans
Parent
commit
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)
 
   if not os.path.exists(options.alert_file):
-    print "Alert file must exist"
-    exit(-1)
+    print "Status is unreported"
+    exit(3)
 
   try:
     with open(options.alert_file, 'r') as f:
       data = json.load(f)
 
-      first = True
+      found = False
       buf = ''
 
       for_hosts = data[options.alert_name]
@@ -66,13 +66,17 @@ def main():
             print str(alert_text)
             exit(1)
           else:
-            if not first:
+            if found:
               buf = buf + ', '
             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:
     traceback.print_exc()