def read_callback():
 for host in ZK_HOSTS:
  try:
   zk = ZooKeeperServer(host)
   stats = zk.get_stats()
   for (k, v) in stats.items():
    try:
     val = collectd.Values(plugin='zookeeper', meta={'0': True})
     val.type = ('counter' if (k in COUNTERS) else 'gauge')
     val.type_instance = k
     val.values = [v]
     val.dispatch()
    except (TypeError, ValueError):
     collectd.error(('error dispatching stat; host=%s, key=%s, val=%s' % (host, k, v)))
     pass
  except socket.error as e:
   log(('unable to connect to server "%s"' % host))
 return stats

def read_callback ( ) : for host in ZK_HOSTS : try : zk = ZooKeeperServer ( host ) stats = zk . get_stats ( ) for ( k , v ) in stats . items ( ) : try : val = collectd . Values ( plugin = 'zookeeper' , meta = { '0' : True } ) val . type = ( 'counter' if ( k in COUNTERS ) else 'gauge' ) val . type_instance = k val . values = [ v ] val . dispatch ( ) except ( TypeError , ValueError ) : collectd . error ( ( 'error dispatching stat; host=%s, key=%s, val=%s' % ( host , k , v ) ) ) pass except socket . error as e : log ( ( 'unable to connect to server "%s"' % host ) ) return stats
parse stats response from marathon .