/**
* 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"
port = MEMCACHED_DEF_PORT;
}
- if ((ai_return = getaddrinfo (host, port, NULL, &ai_list)) != 0) {
+ if ((ai_return = getaddrinfo (host, port, &ai_hints, &ai_list)) != 0) {
char errbuf[1024];
ERROR ("memcached: getaddrinfo (%s, %s): %s",
host, port,
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));
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;
{
const char *name = fields[1] + 4;
submit_counter ("memcached_command", name, atoll (fields[2]));
+ if (strcmp (name, "get") == 0)
+ gets = atof (fields[2]);
}
/*
else if (FIELD_IS ("get_hits"))
{
submit_counter ("memcached_ops", "hits", atoll (fields[2]));
+ hits = atof (fields[2]);
}
else if (FIELD_IS ("get_misses"))
{
if ((octets_rx != 0) || (octets_tx != 0))
submit_counter2 ("memcached_octets", NULL, octets_rx, octets_tx);
+ 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;
}
/* }}} */