<s> """<STR_LIT>""" <EOL> import diamond . collector <EOL> import os <EOL> import re <EOL> class VMStatCollector ( diamond . collector . Collector ) : <EOL> PROC = '<STR_LIT>' <EOL> MAX_VALUES = { <EOL> '<STR_LIT>' : diamond . collector . MAX_COUNTER , <EOL> '<STR_LIT>' : diamond . collector . MAX_COUNTER , <EOL> '<STR_LIT>' : diamond . collector . MAX_COUNTER , <EOL> '<STR_LIT>' : diamond . collector . MAX_COUNTER , <EOL> } <EOL> def get_default_config_help ( self ) : <EOL> config_help = super ( VMStatCollector , 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 ( VMStatCollector , self ) . get_default_config ( ) <EOL> config . update ( { <EOL> '<STR_LIT:path>' : '<STR_LIT>' <EOL> } ) <EOL> return config <EOL> def collect ( self ) : <EOL> if not os . access ( self . PROC , os . R_OK ) : <EOL> return None <EOL> results = { } <EOL> file = open ( self . PROC ) <EOL> exp = '<STR_LIT>' <EOL> reg = re . compile ( exp ) <EOL> for line in file : <EOL> match = reg . match ( line ) <EOL> if match : <EOL> name = match . group ( <NUM_LIT:1> ) <EOL> value = match . group ( <NUM_LIT:2> ) <EOL> results [ name ] = self . derivative ( name , <EOL> int ( value ) , <EOL> self . MAX_VALUES [ name ] ) <EOL> file . close ( ) <EOL> for key , value in results . items ( ) : <EOL> self . publish ( key , value , <NUM_LIT:2> ) </s>
