<s> """<STR_LIT>""" <EOL> import diamond . collector <EOL> import re <EOL> import os <EOL> from diamond . collector import str_to_bool <EOL> class LoadAverageCollector ( diamond . collector . Collector ) : <EOL> PROC_LOADAVG = '<STR_LIT>' <EOL> PROC_LOADAVG_RE = re . compile ( r'<STR_LIT>' ) <EOL> def get_default_config_help ( self ) : <EOL> config_help = super ( LoadAverageCollector , <EOL> 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 ( LoadAverageCollector , self ) . get_default_config ( ) <EOL> config . update ( { <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:False>' <EOL> } ) <EOL> return config <EOL> def collect ( self ) : <EOL> load01 , load05 , load15 = os . getloadavg ( ) <EOL> if not str_to_bool ( self . config [ '<STR_LIT>' ] ) : <EOL> self . publish_gauge ( '<STR_LIT>' , load01 , <NUM_LIT:2> ) <EOL> self . publish_gauge ( '<STR_LIT>' , load05 , <NUM_LIT:2> ) <EOL> self . publish_gauge ( '<STR_LIT>' , load15 , <NUM_LIT:2> ) <EOL> else : <EOL> self . publish_gauge ( '<STR_LIT>' , load01 , <NUM_LIT:2> ) <EOL> if os . access ( self . PROC_LOADAVG , os . R_OK ) : <EOL> file = open ( self . PROC_LOADAVG ) <EOL> for line in file : <EOL> match = self . PROC_LOADAVG_RE . match ( line ) <EOL> if match : <EOL> self . publish_gauge ( '<STR_LIT>' , int ( match . group ( <NUM_LIT:4> ) ) ) <EOL> self . publish_gauge ( '<STR_LIT>' , int ( match . group ( <NUM_LIT:5> ) ) ) <EOL> file . close ( ) </s>
