collectd-memcached-bucket

Grab stats for individual buckets in the NorthMemCouchScaleBase bucket engine and shove them into collectd
git clone https://code.literati.org/collectd-memcached-bucket.git
Log | Files | Refs

commit 49fb647314b66b711f7d1994b9a950da334b23c6
parent a58ea859b716cc09b9cfb13c31b4e1aaeb10e5a7
Author: Sean Lynch <seanl@literati.org>
Date:   Wed, 17 Mar 2010 00:21:29 +0000

Work around broken list command

Diffstat:
Mcollectd_memcached_buckets.py | 35++++++++++++++++++++++++-----------
1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/collectd_memcached_buckets.py b/collectd_memcached_buckets.py @@ -70,6 +70,14 @@ def put_values(c, hostname, bucket, now, values): c.putval(identifier, now, values) +def list_buckets(mc): + # return mc.bucket_list() + buckets = [] + for line in open('/var/db/memcached.pw'): + buckets.append(line.split()[0]) + + return buckets + def main(): from optparse import OptionParser @@ -88,20 +96,25 @@ def main(): hostname = options.hostname or get_hostname_from_collectd_config('/etc/collectd/collectd.conf') assert hostname c = pycollectd.Exec() - l = mc.bucket_list() + l = list_buckets(mc) now = time.time() totals = None for bucket in l: - mc.bucket_select(bucket) - values = get_bucket_stats(mc) - if totals is None: - totals = values[:] - else: - for i in xrange(len(totals)): - totals[i] += values[i] - totals[i] &= MASK - - put_values(c, hostname, bucket, now, values) + try: + mc.bucket_select(bucket) + values = get_bucket_stats(mc) + if totals is None: + totals = values[:] + else: + for i in xrange(len(totals)): + totals[i] += values[i] + totals[i] &= MASK + + put_values(c, hostname, bucket, now, values) + except: + #import traceback + #traceback.print_exc() + pass put_values(c, hostname, 'ALL', now, totals)