From: Doug MacEachern Date: Thu, 8 Jan 2009 01:58:49 +0000 (-0800) Subject: memcached plugin: Add hitratio metric. X-Git-Tag: collectd-4.6.0~100 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=9008c5e4223b6c75aacac8a66f5eabbbef517d85;p=collectd.git memcached plugin: Add hitratio metric. Signed-off-by: Doug MacEachern Signed-off-by: Florian Forster --- diff --git a/src/memcached.c b/src/memcached.c index 7bdad0a0..fb33880f 100644 --- a/src/memcached.c +++ b/src/memcached.c @@ -321,6 +321,8 @@ static int memcached_read (void) /* {{{ */ gauge_t bytes_used = NAN; gauge_t bytes_total = NAN; + gauge_t hits = NAN; + gauge_t gets = NAN; counter_t rusage_user = 0; counter_t rusage_syst = 0; counter_t octets_rx = 0; @@ -430,6 +432,8 @@ static int memcached_read (void) /* {{{ */ { const char *name = fields[1] + 4; submit_counter ("memcached_command", name, atoll (fields[2])); + if (strcmp (name, "get") == 0) + gets = atof (fields[2]); } /* @@ -438,6 +442,7 @@ static int memcached_read (void) /* {{{ */ else if (FIELD_IS ("get_hits")) { submit_counter ("memcached_ops", "hits", atoll (fields[2])); + hits = atof (fields[2]); } else if (FIELD_IS ("get_misses")) { @@ -470,6 +475,8 @@ static int memcached_read (void) /* {{{ */ if ((octets_rx != 0) || (octets_tx != 0)) submit_counter2 ("memcached_octets", NULL, octets_rx, octets_tx); + if (! isnan (gets) && !isnan (hits)) + submit_gauge ("percent", "hitratio", (hits / gets) * 100.0); return 0; } /* }}} */