<s> """<STR_LIT>""" <EOL> import platform <EOL> import os <EOL> import diamond . collector <EOL> if platform . architecture ( ) [ <NUM_LIT:0> ] == '<STR_LIT>' : <EOL> counter = ( <NUM_LIT:2> ** <NUM_LIT:64> ) - <NUM_LIT:1> <EOL> else : <EOL> counter = ( <NUM_LIT:2> ** <NUM_LIT:32> ) - <NUM_LIT:1> <EOL> class InterruptCollector ( diamond . collector . Collector ) : <EOL> PROC = '<STR_LIT>' <EOL> def get_default_config_help ( self ) : <EOL> config_help = super ( InterruptCollector , 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 ( InterruptCollector , 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> if not os . access ( self . PROC , os . R_OK ) : <EOL> return False <EOL> file = open ( self . PROC , '<STR_LIT:r>' ) <EOL> cpuCount = None <EOL> for line in file : <EOL> if not cpuCount : <EOL> cpuCount = len ( line . split ( ) ) <EOL> else : <EOL> data = line . strip ( ) . split ( None , cpuCount + <NUM_LIT:2> ) <EOL> data [ <NUM_LIT:0> ] = data [ <NUM_LIT:0> ] . replace ( '<STR_LIT::>' , '<STR_LIT>' ) <EOL> if len ( data ) == <NUM_LIT:2> : <EOL> metric_name = data [ <NUM_LIT:0> ] <EOL> metric_value = data [ <NUM_LIT:1> ] <EOL> self . publish ( metric_name , <EOL> self . derivative ( metric_name , <EOL> long ( metric_value ) , <EOL> counter ) ) <EOL> else : <EOL> if len ( data [ <NUM_LIT:0> ] ) == cpuCount + <NUM_LIT:1> : <EOL> metric_name = data [ <NUM_LIT:0> ] + '<STR_LIT:.>' <EOL> elif len ( data [ <NUM_LIT:0> ] ) == <NUM_LIT:3> : <EOL> metric_name = ( ( ( data [ - <NUM_LIT:2> ] + '<STR_LIT:U+0020>' <EOL> + data [ - <NUM_LIT:1> ] ) . replace ( '<STR_LIT:U+0020>' , '<STR_LIT:_>' ) ) + '<STR_LIT:.>' ) <EOL> else : <EOL> metric_name = ( ( ( data [ - <NUM_LIT:2> ] ) . replace ( '<STR_LIT:U+0020>' , '<STR_LIT:_>' ) ) <EOL> + '<STR_LIT:.>' <EOL> + ( ( data [ - <NUM_LIT:1> ] ) . replace ( '<STR_LIT:U+002CU+0020>' , <EOL> '<STR_LIT:->' <EOL> ) . replace ( '<STR_LIT:U+0020>' , <EOL> '<STR_LIT:_>' ) ) <EOL> + '<STR_LIT:.>' + data [ <NUM_LIT:0> ] + '<STR_LIT:.>' ) <EOL> total = <NUM_LIT:0> <EOL> for index , value in enumerate ( data ) : <EOL> if index == <NUM_LIT:0> or index >= cpuCount + <NUM_LIT:1> : <EOL> continue <EOL> metric_name_node = metric_name + '<STR_LIT>' + str ( index - <NUM_LIT:1> ) <EOL> value = int ( self . derivative ( metric_name_node , <EOL> long ( value ) , counter ) ) <EOL> total += value <EOL> self . publish ( metric_name_node , value ) <EOL> metric_name_node = metric_name + '<STR_LIT>' <EOL> self . publish ( metric_name_node , total ) <EOL> file . close ( ) </s>
