def collect_stats(bin_dir, bucket):
 if (not os.path.isfile(('%s/cbstats' % bin_dir))):
  return
 cli = ('%s/cbstats' % bin_dir)
 try:
  ts = time.time()
  stats = subprocess.check_output([cli, 'localhost:11211', '-b', bucket, 'all'])
 except subprocess.CalledProcessError:
  return
 for stat in stats.splitlines():
  metric = stat.split(':')[0].lstrip(' ')
  value = stat.split(':')[1].lstrip('  DCTB ')
  if (metric in KEYS):
   print ('couchbase.%s %i %s bucket=%s' % (metric, ts, value, bucket))

def collect_stats ( bin_dir , bucket ) : if ( not os . path . isfile ( ( '%s/cbstats' % bin_dir ) ) ) : return cli = ( '%s/cbstats' % bin_dir ) try : ts = time . time ( ) stats = subprocess . check_output ( [ cli , 'localhost:11211' , '-b' , bucket , 'all' ] ) except subprocess . CalledProcessError : return for stat in stats . splitlines ( ) : metric = stat . split ( ':' ) [ 0 ] . lstrip ( ' ' ) value = stat . split ( ':' ) [ 1 ] . lstrip ( '  DCTB ' ) if ( metric in KEYS ) : print ( 'couchbase.%s %i %s bucket=%s' % ( metric , ts , value , bucket ) )
returns statistics related to a particular bucket .