#NEWLINE# def check_health( self ) : #NEWLINE# #INDENT# imp_map = { #NEWLINE# #INDENT# 'OK' : 'GREEN' , #NEWLINE# 'WARNING' : 'YELLOW' , #NEWLINE# 'CRITICAL' : 'RED' , #NEWLINE# #UNINDENT# } #NEWLINE# other_map = { #NEWLINE# #INDENT# 'OK' : 'GREEN' , #NEWLINE# #UNINDENT# } #NEWLINE# color_counter = collections . Counter ( ) #NEWLINE# important_services = self . get_important_services ( ) #NEWLINE# for alert in self . provider . get_alerts_data ( self . service ) : #NEWLINE# #INDENT# alert_summary = alert . get ( 'state' , 'UNKNOWN' ) #NEWLINE# if ( self . service in imp_map ) : #NEWLINE# #INDENT# target = imp_map . get ( alert_summary , 'RED' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# target = other_map . get ( alert_summary , 'YELLOW' ) #NEWLINE# #UNINDENT# color_counter [ target ] += 1 #NEWLINE# #UNINDENT# if ( ( color_counter [ 'RED' ] > 0 ) and ( color_counter [ 'YELLOW' ] > 0 ) ) : #NEWLINE# #INDENT# raise health_check_base . RedHealthError ( ( _ ( 'Ambari Monitor has responded that cluster has %(red)d critical and %(yellow)d warning alert(s)' ) % { #NEWLINE# #INDENT# 'red' : color_counter [ 'RED' ] , #NEWLINE# 'yellow' : color_counter [ 'YELLOW' ] , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( color_counter [ 'RED' ] > 0 ) : #NEWLINE# #INDENT# raise health_check_base . RedHealthError ( ( _ ( 'Ambari Monitor has responded that cluster has %(red)d critical alert(s)' ) % { #NEWLINE# #INDENT# 'red' : color_counter [ 'RED' ] , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( color_counter [ 'YELLOW' ] > 0 ) : #NEWLINE# #INDENT# raise health_check_base . YellowHealthError ( ( _ ( 'Ambari Monitor has responded that cluster has %d warning alert(s)' ) % color_counter [ 'YELLOW' ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return _ ( 'No alerts found' )