<s> """<STR_LIT>""" <EOL> import diamond . collector <EOL> import re <EOL> class DRBDCollector ( diamond . collector . Collector ) : <EOL> """<STR_LIT>""" <EOL> def get_default_config_help ( self ) : <EOL> config_help = super ( DRBDCollector , self ) . get_default_config_help ( ) <EOL> config_help . update ( { <EOL> } ) <EOL> return config_help <EOL> def get_default_config ( self ) : <EOL> """<STR_LIT>""" <EOL> config = super ( DRBDCollector , self ) . get_default_config ( ) <EOL> config . update ( { <EOL> '<STR_LIT:path>' : '<STR_LIT>' <EOL> } ) <EOL> return config <EOL> def collect ( self ) : <EOL> """<STR_LIT>""" <EOL> performance_indicators = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> results = dict ( ) <EOL> try : <EOL> statusfile = open ( '<STR_LIT>' , '<STR_LIT:r>' ) <EOL> current_resource = '<STR_LIT>' <EOL> for line in statusfile : <EOL> if re . search ( '<STR_LIT:version>' , line ) is None : <EOL> if re . search ( r'<STR_LIT>' , line ) : <EOL> matches = re . match ( r'<STR_LIT>' <EOL> '<STR_LIT>' , line ) <EOL> current_resource = matches . group ( <NUM_LIT:1> ) <EOL> results [ current_resource ] = dict ( ) <EOL> elif re . search ( r'<STR_LIT>' , line ) : <EOL> metrics = line . strip ( ) . split ( "<STR_LIT:U+0020>" ) <EOL> for metric in metrics : <EOL> item , value = metric . split ( "<STR_LIT::>" ) <EOL> results [ current_resource ] [ <EOL> performance_indicators [ item ] ] = value <EOL> else : <EOL> continue <EOL> statusfile . close ( ) <EOL> except IOError , errormsg : <EOL> self . log . error ( "<STR_LIT>" . format ( errormsg ) ) <EOL> return <EOL> for resource in results . keys ( ) : <EOL> for metric_name , metric_value in results [ resource ] . items ( ) : <EOL> if metric_value . isdigit ( ) : <EOL> self . publish ( resource + "<STR_LIT:.>" + metric_name , metric_value ) <EOL> else : <EOL> continue </s>
