/**
* collectd - src/memcached.c, based on src/hddtemp.c
- * Copyright (C) 2007 Antony Dovgal
- * Copyright (C) 2005,2006 Vincent Stehlé
+ * Copyright (C) 2007 Antony Dovgal
+ * Copyright (C) 2007-2009 Florian Forster
+ * Copyright (C) 2009 Doug MacEachern
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
*
* Authors:
* Antony Dovgal <tony at daylessday dot org>
- * Vincent Stehlé <vincent.stehle at free.fr>
* Florian octo Forster <octo at verplant.org>
+ * Doug MacEachern <dougm at hyperic.com>
**/
#include "collectd.h"
vl.values = values;
vl.values_len = 1;
- vl.time = time (NULL);
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "memcached", sizeof (vl.plugin));
sstrncpy (vl.type, type, sizeof (vl.type));
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;
}
/* }}} */