<s> """<STR_LIT>""" <EOL> import sys <EOL> import os <EOL> import time <EOL> import struct <EOL> sys . path . append ( os . path . abspath ( os . path . join ( os . path . dirname ( __file__ ) , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ) ) ) <EOL> from diamond . metric import Metric <EOL> from snmp import SNMPCollector as parent_SNMPCollector <EOL> class IODriveSNMPCollector ( parent_SNMPCollector ) : <EOL> """<STR_LIT>""" <EOL> IODRIVE_STATS = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } <EOL> IODRIVE_BYTE_STATS = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } <EOL> MAX_VALUE = <NUM_LIT> <EOL> def get_default_config_help ( self ) : <EOL> config_help = super ( IODriveSNMPCollector , <EOL> self ) . get_default_config_help ( ) <EOL> config_help . update ( { <EOL> '<STR_LIT:host>' : '<STR_LIT>' , <EOL> '<STR_LIT:port>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } ) <EOL> return config_help <EOL> def get_default_config ( self ) : <EOL> """<STR_LIT>""" <EOL> config = super ( IODriveSNMPCollector , self ) . get_default_config ( ) <EOL> config . update ( { <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:15> , <EOL> } ) <EOL> return config <EOL> def get_string_index_oid ( self , s ) : <EOL> """<STR_LIT>""" <EOL> return ( len ( self . get_bytes ( s ) ) , ) + self . get_bytes ( s ) <EOL> def get_bytes ( self , s ) : <EOL> """<STR_LIT>""" <EOL> return struct . unpack ( '<STR_LIT>' % len ( s ) , s ) <EOL> def collect_snmp ( self , device , host , port , community ) : <EOL> """<STR_LIT>""" <EOL> timestamp = time . time ( ) <EOL> for k , v in self . IODRIVE_STATS . items ( ) : <EOL> metricName = '<STR_LIT:.>' . join ( [ k ] ) <EOL> metricValue = int ( self . get ( v , host , port , community ) [ v ] ) <EOL> metricPath = '<STR_LIT:.>' . join ( [ '<STR_LIT>' , host , device , metricName ] ) <EOL> metric = Metric ( metricPath , metricValue , timestamp , <NUM_LIT:0> ) <EOL> self . publish_metric ( metric ) <EOL> for k , v in self . IODRIVE_BYTE_STATS . items ( ) : <EOL> metricName = '<STR_LIT:.>' . join ( [ k ] ) <EOL> metricValue = int ( self . get ( v , host , port , community ) [ v ] ) <EOL> metricPath = '<STR_LIT:.>' . join ( [ '<STR_LIT>' , host , device , metricName ] ) <EOL> metric = Metric ( metricPath , metricValue , timestamp , <NUM_LIT:0> ) <EOL> self . publish_metric ( metric ) </s>
