<s> """<STR_LIT>""" <EOL> import diamond . collector <EOL> import sys <EOL> import urllib2 <EOL> if sys . version_info >= ( <NUM_LIT:2> , <NUM_LIT:5> ) : <EOL> import xml . etree . cElementTree as ElementTree <EOL> else : <EOL> import cElementTree as ElementTree <EOL> class BindCollector ( diamond . collector . Collector ) : <EOL> def get_default_config_help ( self ) : <EOL> config_help = super ( BindCollector , 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> + "<STR_LIT>" <EOL> + "<STR_LIT>" <EOL> + "<STR_LIT>" <EOL> + "<STR_LIT>" <EOL> + "<STR_LIT>" , <EOL> '<STR_LIT>' : "<STR_LIT>" , <EOL> '<STR_LIT>' : "<STR_LIT>" , <EOL> } ) <EOL> return config_help <EOL> def get_default_config ( self ) : <EOL> """<STR_LIT>""" <EOL> config = super ( BindCollector , self ) . get_default_config ( ) <EOL> config . update ( { <EOL> '<STR_LIT:host>' : '<STR_LIT:localhost>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False , <EOL> } ) <EOL> return config <EOL> def clean_counter ( self , name , value ) : <EOL> value = self . derivative ( name , value ) <EOL> if value < <NUM_LIT:0> : <EOL> value = <NUM_LIT:0> <EOL> self . publish ( name , value ) <EOL> def collect ( self ) : <EOL> try : <EOL> req = urllib2 . urlopen ( '<STR_LIT>' % ( <EOL> self . config [ '<STR_LIT:host>' ] , int ( self . config [ '<STR_LIT:port>' ] ) ) ) <EOL> except Exception , e : <EOL> self . log . error ( '<STR_LIT>' , e ) <EOL> return { } <EOL> tree = ElementTree . parse ( req ) <EOL> if not tree : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> root = tree . find ( '<STR_LIT>' ) <EOL> if '<STR_LIT>' in self . config [ '<STR_LIT>' ] : <EOL> for view in root . findall ( '<STR_LIT>' ) : <EOL> name = view . find ( '<STR_LIT:name>' ) . text <EOL> if name == '<STR_LIT>' and not self . config [ '<STR_LIT>' ] : <EOL> continue <EOL> if name == '<STR_LIT>' and not self . config [ '<STR_LIT>' ] : <EOL> continue <EOL> nzones = len ( view . findall ( '<STR_LIT>' ) ) <EOL> self . publish ( '<STR_LIT>' % name , nzones ) <EOL> for counter in view . findall ( '<STR_LIT>' ) : <EOL> self . clean_counter ( <EOL> '<STR_LIT>' % ( name , <EOL> counter . find ( '<STR_LIT:name>' ) . text ) , <EOL> int ( counter . find ( '<STR_LIT>' ) . text ) <EOL> ) <EOL> for counter in view . findall ( '<STR_LIT>' ) : <EOL> self . clean_counter ( <EOL> '<STR_LIT>' % ( name , <EOL> counter . find ( '<STR_LIT:name>' ) . text ) , <EOL> int ( counter . find ( '<STR_LIT>' ) . text ) <EOL> ) <EOL> for counter in view . findall ( '<STR_LIT>' ) : <EOL> self . clean_counter ( <EOL> '<STR_LIT>' % ( <EOL> name , counter . find ( '<STR_LIT:name>' ) . text . replace ( '<STR_LIT:!>' , <EOL> '<STR_LIT>' ) ) , <EOL> int ( counter . find ( '<STR_LIT>' ) . text ) <EOL> ) <EOL> if '<STR_LIT>' in self . config [ '<STR_LIT>' ] : <EOL> for counter in root . findall ( '<STR_LIT>' ) : <EOL> self . clean_counter ( <EOL> '<STR_LIT>' % counter . find ( '<STR_LIT:name>' ) . text , <EOL> int ( counter . find ( '<STR_LIT>' ) . text ) <EOL> ) <EOL> for counter in root . findall ( '<STR_LIT>' ) : <EOL> self . clean_counter ( <EOL> '<STR_LIT>' % counter . find ( '<STR_LIT:name>' ) . text , <EOL> int ( counter . find ( '<STR_LIT>' ) . text ) <EOL> ) <EOL> for counter in root . findall ( '<STR_LIT>' ) : <EOL> self . clean_counter ( <EOL> '<STR_LIT>' % counter . find ( '<STR_LIT:name>' ) . text , <EOL> int ( counter . find ( '<STR_LIT>' ) . text ) <EOL> ) <EOL> if '<STR_LIT>' in self . config [ '<STR_LIT>' ] : <EOL> for counter in root . findall ( '<STR_LIT>' ) : <EOL> self . clean_counter ( <EOL> '<STR_LIT>' % counter . find ( '<STR_LIT:name>' ) . text , <EOL> int ( counter . find ( '<STR_LIT>' ) . text ) <EOL> ) <EOL> if '<STR_LIT>' in self . config [ '<STR_LIT>' ] : <EOL> for counter in root . findall ( '<STR_LIT>' ) : <EOL> self . clean_counter ( <EOL> '<STR_LIT>' % counter . find ( '<STR_LIT:name>' ) . text , <EOL> int ( counter . find ( '<STR_LIT>' ) . text ) <EOL> ) <EOL> if '<STR_LIT>' in self . config [ '<STR_LIT>' ] : <EOL> for counter in root . find ( '<STR_LIT>' ) . getchildren ( ) : <EOL> self . publish ( <EOL> '<STR_LIT>' % counter . tag , <EOL> int ( counter . text ) <EOL> ) </s>
