<s> """<STR_LIT>""" <EOL> import diamond . collector <EOL> import os <EOL> class UDPCollector ( diamond . collector . Collector ) : <EOL> PROC = [ <EOL> '<STR_LIT>' <EOL> ] <EOL> def process_config ( self ) : <EOL> super ( UDPCollector , self ) . process_config ( ) <EOL> if self . config [ '<STR_LIT>' ] is None : <EOL> self . config [ '<STR_LIT>' ] = [ ] <EOL> def get_default_config_help ( self ) : <EOL> config_help = super ( UDPCollector , self ) . get_default_config_help ( ) <EOL> config_help . update ( { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } ) <EOL> return config_help <EOL> def get_default_config ( self ) : <EOL> """<STR_LIT>""" <EOL> config = super ( UDPCollector , self ) . get_default_config ( ) <EOL> config . update ( { <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' + <EOL> '<STR_LIT>' <EOL> } ) <EOL> return config <EOL> def collect ( self ) : <EOL> metrics = { } <EOL> for filepath in self . PROC : <EOL> if not os . access ( filepath , os . R_OK ) : <EOL> self . log . error ( '<STR_LIT>' , filepath ) <EOL> continue <EOL> header = '<STR_LIT>' <EOL> data = '<STR_LIT>' <EOL> file = open ( filepath ) <EOL> if not file : <EOL> self . log . error ( '<STR_LIT>' , filepath ) <EOL> continue <EOL> while True : <EOL> line = file . readline ( ) <EOL> if len ( line ) == <NUM_LIT:0> : <EOL> break <EOL> if line . startswith ( "<STR_LIT>" ) : <EOL> header = line <EOL> data = file . readline ( ) <EOL> break <EOL> file . close ( ) <EOL> if header == '<STR_LIT>' or data == '<STR_LIT>' : <EOL> self . log . error ( '<STR_LIT>' , filepath ) <EOL> continue <EOL> header = header . split ( ) <EOL> data = data . split ( ) <EOL> for i in xrange ( <NUM_LIT:1> , len ( header ) ) : <EOL> metrics [ header [ i ] ] = data [ i ] <EOL> for metric_name in metrics . keys ( ) : <EOL> if ( ( len ( self . config [ '<STR_LIT>' ] ) > <NUM_LIT:0> and <EOL> metric_name not in self . config [ '<STR_LIT>' ] ) ) : <EOL> continue <EOL> value = metrics [ metric_name ] <EOL> value = self . derivative ( metric_name , long ( value ) ) <EOL> self . publish ( metric_name , value , <NUM_LIT:0> ) </s>
