Browse Source

AMBARI-6758. Flume: alerts reported incorrectly by Nagios (ncole)

Nate Cole 11 năm trước cách đây
mục cha
commit
d2413e1129

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

@@ -51,32 +51,25 @@ def main():
     with open(options.alert_file, 'r') as f:
     with open(options.alert_file, 'r') as f:
       data = json.load(f)
       data = json.load(f)
 
 
-      found = False
-      buf = ''
+      buf_list = []
+      exit_code = 0
 
 
       for_hosts = data[options.alert_name]
       for_hosts = data[options.alert_name]
       if for_hosts.has_key(options.host):
       if for_hosts.has_key(options.host):
         for host_entry in for_hosts[options.host]:
         for host_entry in for_hosts[options.host]:
+          buf_list.append(host_entry['text'])
           alert_state = host_entry['state']
           alert_state = host_entry['state']
-          alert_text = host_entry['text']
-          if alert_state == 'CRITICAL':
-            print str(alert_text)
-            exit(2)
-          elif alert_state == 'WARNING':
-            print str(alert_text)
-            exit(1)
-          else:
-            if found:
-              buf = buf + ', '
-            buf = buf + alert_text
-            found = True
+          if alert_state == 'CRITICAL' and exit_code < 2:
+            exit_code = 2
+          elif alert_state == 'WARNING' and exit_code < 1:
+            exit_code = 1
 
 
-      if not found:
+      if 0 == len(buf_list):
         print "Status is not reported"
         print "Status is not reported"
         exit(3)
         exit(3)
       else:
       else:
-        print buf
-        exit(0)
+        print ", ".join(buf_list)
+        exit(exit_code)
       
       
   except Exception:
   except Exception:
     traceback.print_exc()
     traceback.print_exc()

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/files/check_wrapper.sh

@@ -47,7 +47,7 @@ function real_component() {
       realCompName="HIVE_SERVER"
       realCompName="HIVE_SERVER"
     ;;
     ;;
     FLUME)
     FLUME)
-      realCompName="FLUME_SERVER"
+      realCompName="FLUME_HANDLER"
     ;;
     ;;
     HUE)
     HUE)
       realCompName="HUE_SERVER"
       realCompName="HUE_SERVER"