projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bump for ChangeLog re-check
[collectd.git]
/
src
/
memcached.c
diff --git
a/src/memcached.c
b/src/memcached.c
index
d62b25d
..
c00f53e
100644
(file)
--- a/
src/memcached.c
+++ b/
src/memcached.c
@@
-32,8
+32,8
@@
#include "collectd.h"
#include "collectd.h"
-#include "common.h"
#include "plugin.h"
#include "plugin.h"
+#include "utils/common/common.h"
#include <netdb.h>
#include <netinet/in.h>
#include <netdb.h>
#include <netinet/in.h>
@@
-69,7
+69,7
@@
struct memcached_s {
};
typedef struct memcached_s memcached_t;
};
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;
static void memcached_free(void *arg) {
memcached_t *st = arg;
@@
-171,7
+171,8
@@
static int memcached_connect_inet(memcached_t *st) {
/* Wait until connection establishes */
struct pollfd pollfd = {
/* Wait until connection establishes */
struct pollfd pollfd = {
- .fd = fd, .events = POLLOUT,
+ .fd = fd,
+ .events = POLLOUT,
};
do
status = poll(&pollfd, 1, MEMCACHED_CONNECT_TIMEOUT);
};
do
status = poll(&pollfd, 1, MEMCACHED_CONNECT_TIMEOUT);
@@
-226,7
+227,8
@@
static int memcached_query_daemon(char *buffer, size_t buffer_size,
}
struct pollfd pollfd = {
}
struct pollfd pollfd = {
- .fd = st->fd, .events = POLLOUT,
+ .fd = st->fd,
+ .events = POLLOUT,
};
do
};
do
@@
-285,6
+287,12
@@
static int memcached_query_daemon(char *buffer, size_t buffer_size,
close(st->fd);
st->fd = -1;
return -1;
close(st->fd);
st->fd = -1;
return -1;
+ } else if (status == 0) {
+ ERROR("memcached plugin: Instance \"%s\": Connection closed by peer",
+ st->name);
+ close(st->fd);
+ st->fd = -1;
+ return -1;
}
buffer_fill += (size_t)status;
}
buffer_fill += (size_t)status;
@@
-340,7
+348,8
@@
static void submit_derive2(const char *type, const char *type_inst,
derive_t value0, derive_t value1, memcached_t *st) {
value_list_t vl = VALUE_LIST_INIT;
value_t values[] = {
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);
};
memcached_init_vl(&vl, st);
@@
-371,7
+380,8
@@
static void submit_gauge2(const char *type, const char *type_inst,
gauge_t value0, gauge_t value1, memcached_t *st) {
value_list_t vl = VALUE_LIST_INIT;
value_t values[] = {
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);
};
memcached_init_vl(&vl, st);
@@
-469,7
+479,7
@@
static int memcached_read(user_data_t *user_data) {
if (strsplit(line, fields, 3) != 3)
continue;
if (strsplit(line, fields, 3) != 3)
continue;
-
in
t name_len = strlen(fields[1]);
+
size_
t name_len = strlen(fields[1]);
if (name_len == 0)
continue;
if (name_len == 0)
continue;
@@
-503,6
+513,13
@@
static int memcached_read(user_data_t *user_data) {
}
/*
}
/*
+ * 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")) {
* Number of bytes used and available (total - used)
*/
else if (FIELD_IS("bytes")) {
@@
-679,7
+696,8
@@
static int memcached_add_read_callback(memcached_t *st) {
/* callback = */ memcached_read,
/* interval = */ 0,
&(user_data_t){
/* 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 memcached_add_read_callback */
@@
-696,7
+714,7
@@
static int config_add_instance(oconfig_item_t *ci) {
int status = 0;
/* Disable automatic generation of default instance in the init 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) {
memcached_t *st = calloc(1, sizeof(*st));
if (st == NULL) {
@@
-749,7
+767,7
@@
static int config_add_instance(oconfig_item_t *ci) {
} /* int config_add_instance */
static int memcached_config(oconfig_item_t *ci) {
} /* int config_add_instance */
static int memcached_config(oconfig_item_t *ci) {
-
_B
ool have_instance_block = 0;
+
b
ool have_instance_block = 0;
for (int i = 0; i < ci->children_num; i++) {
oconfig_item_t *child = ci->children + i;
for (int i = 0; i < ci->children_num; i++) {
oconfig_item_t *child = ci->children + i;
@@
-791,7
+809,7
@@
static int memcached_init(void) {
int status = memcached_add_read_callback(st);
if (status == 0)
int status = memcached_add_read_callback(st);
if (status == 0)
- memcached_have_instances =
1
;
+ memcached_have_instances =
true
;
return status;
} /* int memcached_init */
return status;
} /* int memcached_init */