#NEWLINE# def check_max_open_files( opts ) : #NEWLINE# #INDENT# '\n    Check the number of max allowed open files and adjust if needed\n    ' #NEWLINE# mof_c = opts . get ( 'max_open_files' , 100000 ) #NEWLINE# if sys . platform . startswith ( 'win' ) : #NEWLINE# #INDENT# mof_s = mof_h = win32file . _getmaxstdio ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( mof_s , mof_h ) = resource . getrlimit ( resource . RLIMIT_NOFILE ) #NEWLINE# #UNINDENT# accepted_keys_dir = os . path . join ( opts . get ( 'pki_dir' ) , 'minions' ) #NEWLINE# accepted_count = len ( os . listdir ( accepted_keys_dir ) ) #NEWLINE# log . debug ( 'This salt-master instance has accepted {0} minion keys.' . format ( opts ) ) #NEWLINE# level = logging . INFO #NEWLINE# if ( ( accepted_count * 4 ) <= mof_s ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# msg = 'The number of accepted minion keys({0}) should be lower than 1/4 of the max open files soft setting({1}). ' . format ( accepted_count , mof_s ) #NEWLINE# if ( accepted_count >= mof_s ) : #NEWLINE# #INDENT# msg += 'salt-master will crash pretty soon! ' #NEWLINE# level = logging . CRITICAL #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( accepted_count * 2 ) >= mof_s ) : #NEWLINE# #INDENT# level = logging . CRITICAL #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( accepted_count * 3 ) >= mof_s ) : #NEWLINE# #INDENT# level = logging . WARNING #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( accepted_count * 4 ) >= mof_s ) : #NEWLINE# #INDENT# level = logging . INFO #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( mof_c < mof_h ) : #NEWLINE# #INDENT# msg += "According to the system's hard limit, there's still a margin of {0} to raise the salt's max_open_files setting. " . format ( ( mof_h - mof_c ) ) #NEWLINE# #UNINDENT# msg += 'Please consider raising this value.' #NEWLINE# log . log ( level = level , msg = msg )