From: Blake Matheny Date: Wed, 6 Feb 2013 12:04:47 +0000 (-0500) Subject: Add support for incr/decr counts X-Git-Tag: collectd-5.4.0~17 X-Git-Url: https://git.tokkee.org/?p=collectd.git;a=commitdiff_plain;h=259470e31a45e46b8cfcd65b9088d45598aaea7f Add support for incr/decr counts --- diff --git a/src/memcached.c b/src/memcached.c index a09f45ec..535ea847 100644 --- a/src/memcached.c +++ b/src/memcached.c @@ -340,6 +340,10 @@ static int memcached_read (user_data_t *user_data) gauge_t bytes_total = NAN; gauge_t hits = NAN; gauge_t gets = NAN; + gauge_t incr_hits = NAN; + derive_t incr = 0; + gauge_t decr_hits = NAN; + derive_t decr = 0; derive_t rusage_user = 0; derive_t rusage_syst = 0; derive_t octets_rx = 0; @@ -436,6 +440,36 @@ static int memcached_read (user_data_t *user_data) gets = atof (fields[2]); } + /* + * Increment/Decrement + */ + else if (FIELD_IS("incr_misses")) + { + derive_t incr_count = atoll (fields[2]); + submit_derive ("memcached_ops", "incr_misses", incr_count, st); + incr += incr_count; + } + else if (FIELD_IS ("incr_hits")) + { + derive_t incr_count = atoll (fields[2]); + submit_derive ("memcached_ops", "incr_hits", incr_count, st); + incr_hits = atof (fields[2]); + incr += incr_count; + } + else if (FIELD_IS ("decr_misses")) + { + derive_t decr_count = atoll (fields[2]); + submit_derive ("memcached_ops", "decr_misses", decr_count, st); + decr += decr_count; + } + else if (FIELD_IS ("decr_hits")) + { + derive_t decr_count = atoll (fields[2]); + submit_derive ("memcached_ops", "decr_hits", decr_count, st); + decr_hits = atof (fields[2]); + decr += decr_count; + } + /* * Operations on the cache, i. e. cache hits, cache misses and evictions of items */ @@ -485,6 +519,20 @@ static int memcached_read (user_data_t *user_data) submit_gauge ("percent", "hitratio", rate, st); } + if (!isnan (incr_hits) && incr != 0) + { + gauge_t incr_rate = 100.0 * incr_hits / incr; + submit_gauge ("percent", "incr_hitratio", incr_rate, st); + submit_derive ("memcached_ops", "incr", incr, st); + } + + if (!isnan (decr_hits) && decr != 0) + { + gauge_t decr_rate = 100.0 * decr_hits / decr; + submit_gauge ("percent", "decr_hitratio", decr_rate, st); + submit_derive ("memcached_ops", "decr", decr, st); + } + return 0; } /* int memcached_read */