#include "collectd.h"
-#include "common.h"
#include "plugin.h"
+#include "utils/common/common.h"
#include <netdb.h>
#include <netinet/in.h>
};
typedef struct memcached_s memcached_t;
-static _Bool memcached_have_instances = 0;
+static bool memcached_have_instances;
static void memcached_free(void *arg) {
memcached_t *st = arg;
/* Wait until connection establishes */
struct pollfd pollfd = {
- .fd = fd, .events = POLLOUT,
+ .fd = fd,
+ .events = POLLOUT,
};
do
status = poll(&pollfd, 1, MEMCACHED_CONNECT_TIMEOUT);
}
struct pollfd pollfd = {
- .fd = st->fd, .events = POLLOUT,
+ .fd = st->fd,
+ .events = POLLOUT,
};
do
derive_t value0, derive_t value1, memcached_t *st) {
value_list_t vl = VALUE_LIST_INIT;
value_t values[] = {
- {.derive = value0}, {.derive = value1},
+ {.derive = value0},
+ {.derive = value1},
};
memcached_init_vl(&vl, st);
gauge_t value0, gauge_t value1, memcached_t *st) {
value_list_t vl = VALUE_LIST_INIT;
value_t values[] = {
- {.gauge = value0}, {.gauge = value1},
+ {.gauge = value0},
+ {.gauge = value1},
};
memcached_init_vl(&vl, st);
if (strsplit(line, fields, 3) != 3)
continue;
- int name_len = strlen(fields[1]);
+ size_t name_len = strlen(fields[1]);
if (name_len == 0)
continue;
}
/*
+ * Number of secs since the server started
+ */
+ else if (FIELD_IS("uptime")) {
+ submit_gauge("uptime", NULL, atof(fields[2]), st);
+ }
+
+ /*
* Number of bytes used and available (total - used)
*/
else if (FIELD_IS("bytes")) {
/* callback = */ memcached_read,
/* interval = */ 0,
&(user_data_t){
- .data = st, .free_func = memcached_free,
+ .data = st,
+ .free_func = memcached_free,
});
} /* int memcached_add_read_callback */
int status = 0;
/* Disable automatic generation of default instance in the init callback. */
- memcached_have_instances = 1;
+ memcached_have_instances = true;
memcached_t *st = calloc(1, sizeof(*st));
if (st == NULL) {
} /* int config_add_instance */
static int memcached_config(oconfig_item_t *ci) {
- _Bool have_instance_block = 0;
+ bool have_instance_block = 0;
for (int i = 0; i < ci->children_num; i++) {
oconfig_item_t *child = ci->children + i;
int status = memcached_add_read_callback(st);
if (status == 0)
- memcached_have_instances = 1;
+ memcached_have_instances = true;
return status;
} /* int memcached_init */