projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
9008c5e
)
memcached plugin: Make absolutely sure, we don't divide by zero.
author
Florian Forster
<octo@huhu.verplant.org>
Tue, 20 Jan 2009 09:34:51 +0000
(10:34 +0100)
committer
Florian Forster
<octo@huhu.verplant.org>
Tue, 20 Jan 2009 09:34:51 +0000
(10:34 +0100)
It's a well-known fact only Chuck Norris can do that!
src/memcached.c
patch
|
blob
|
history
diff --git
a/src/memcached.c
b/src/memcached.c
index
fb33880
..
f139b71
100644
(file)
--- a/
src/memcached.c
+++ b/
src/memcached.c
@@
-475,8
+475,16
@@
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);
+ if (!isnan (gets) && !isnan (hits))
+ {
+ gauge_t rate = NAN;
+
+ if (gets != 0.0)
+ rate = 100.0 * hits / gets;
+
+ submit_gauge ("percent", "hitratio", rate);
+ }
+
return 0;
}
/* }}} */