#NEWLINE# def run( self ) : #NEWLINE# #INDENT# '\n        Run plugin\n         * get parameters and set defaults\n         * run ConnectionCheck for all host, port combinations in parallel\n        ' #NEWLINE# self . addresses = self . plugin . get_param ( 'Connections' , [ ] ) #NEWLINE# self . timeout = self . plugin . get_param ( 'Timeout' , 10 ) #NEWLINE# if ( ( not self . addresses ) and ( not isinstance ( self . addresses , dict ) ) ) : #NEWLINE# #INDENT# raise Exception ( 'Parameter Connections have to be dictionary of (host, port) tuples' ) #NEWLINE# #UNINDENT# for conn in self . addresses : #NEWLINE# #INDENT# if ( ( not ( isinstance ( conn , tuple ) or isinstance ( conn , list ) ) ) and ( len ( conn ) != 2 ) ) : #NEWLINE# #INDENT# raise Exception ( 'Every parameter has to be a [host, port] list' ) #NEWLINE# #UNINDENT# #UNINDENT# threads = [ ] #NEWLINE# for conn in self . addresses : #NEWLINE# #INDENT# t = ConnectionCheck ( ( conn [ 0 ] , conn [ 1 ] ) , self . timeout ) #NEWLINE# t . start ( ) #NEWLINE# threads . append ( t ) #NEWLINE# #UNINDENT# for t in threads : #NEWLINE# #INDENT# t . join ( ) #NEWLINE# #UNINDENT# err = [ ] #NEWLINE# for t in threads : #NEWLINE# #INDENT# err . extend ( status . err ) #NEWLINE# #UNINDENT# status = 'OK' #NEWLINE# if err : #NEWLINE# #INDENT# status = 'ERROR' #NEWLINE# #UNINDENT# self . result . add_component ( 'Connection' , status , error = err ) #NEWLINE# self . result . set_status ( ) #NEWLINE# return self . result