summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: be78373)
raw | patch | inline | side by side (parent: be78373)
author | Marek Becka <marek.becka@superhosting.cz> | |
Mon, 31 Jul 2017 11:41:25 +0000 (07:41 -0400) | ||
committer | Florian Forster <octo@collectd.org> | |
Mon, 18 Sep 2017 06:37:48 +0000 (08:37 +0200) |
src/synproxy.c | patch | blob | history | |
src/types.db | patch | blob | history |
diff --git a/src/synproxy.c b/src/synproxy.c
index eea65baa2864c229cc03d136b9fd8300c283e5e6..dcfb00822204cebca3899508a8f66c7c9feeddf2 100644 (file)
--- a/src/synproxy.c
+++ b/src/synproxy.c
#error "No applicable input method."
#endif
+#define SYNPROXY_FIELDS 6
+
static const char *synproxy_stat_path = "/proc/net/stat/synproxy";
-static const char *column_names[] = {
+static const char *column_names[SYNPROXY_FIELDS] = {
"entries", "syn_received", "invalid", "valid", "retransmission", "reopened"
};
-static const char *column_types[] = {
- "current_connections", "synproxy_connections", "synproxy_cookies",
- "synproxy_cookies", "synproxy_cookies", "synproxy_connections"
+static const char *column_types[SYNPROXY_FIELDS] = {
+ "current_connections", "connections", "cookies", "cookies", "cookies",
+ "connections"
};
static void synproxy_submit(value_t *results) {
value_list_t vl = VALUE_LIST_INIT;
- for (unsigned n = 1; n < 6; n++) {
+ /* 1st column (entries) is hardcoded to 0 in kernel code */
+ for (size_t n = 1; n < SYNPROXY_FIELDS; n++) {
vl.values = &results[n];
vl.values_len = 1;
}
static int synproxy_read(void) {
- FILE *fh;
char buf[1024];
- value_t results[6];
+ value_t results[SYNPROXY_FIELDS];
int is_header = 1, status = 0;
- fh = fopen(synproxy_stat_path, "r");
+ FILE *fh = fopen(synproxy_stat_path, "r");
if (fh == NULL) {
ERROR("synproxy plugin: unable to open %s", synproxy_stat_path);
return -1;
memset(results, 0, sizeof(results));
while (fgets(buf, sizeof(buf), fh) != NULL) {
- int numfields;
- char *fields[6], *endprt;
+ char *fields[SYNPROXY_FIELDS], *endprt;
if (is_header) {
is_header = 0;
continue;
}
- numfields = strsplit(buf, fields, STATIC_ARRAY_SIZE(fields));
- if (numfields != 6) {
+ int numfields = strsplit(buf, fields, STATIC_ARRAY_SIZE(fields));
+ if (numfields != SYNPROXY_FIELDS) {
ERROR("synproxy plugin: unexpected number of columns in %s",
synproxy_stat_path);
status = -1;
}
/* 1st column (entries) is hardcoded to 0 in kernel code */
- for (unsigned n = 1; n < 6; n++) {
+ for (size_t n = 1; n < SYNPROXY_FIELDS; n++) {
char *endptr = NULL;
errno = 0;
results[n].derive += strtoull(fields[n], &endprt, 16);
if ((endptr == fields[n]) || errno != 0) {
ERROR("synproxy plugin: unable to parse value: %s", fields[n]);
- status = -1;
- goto err_close;
+ fclose(fh);
+ return -1;
}
}
}
-err_close:
fclose(fh);
if (status == 0) {
diff --git a/src/types.db b/src/types.db
index a0a17824be9eabfeda7d67fa10490ddc75aa747e..87a82ee071125090f1653f6b550d446efbd78c45 100644 (file)
--- a/src/types.db
+++ b/src/types.db
connections value:DERIVE:0:U
conntrack value:GAUGE:0:4294967295
contextswitch value:DERIVE:0:U
+cookies value:DERIVE:0:U
count value:GAUGE:0:U
counter value:COUNTER:U:U
cpu value:DERIVE:0:U
spl value:GAUGE:U:U
swap value:GAUGE:0:1099511627776
swap_io value:DERIVE:0:U
-synproxy_connections value:DERIVE:0:U
-synproxy_cookies value:DERIVE:0:U
tcp_connections value:GAUGE:0:4294967295
temperature value:GAUGE:U:U
threads value:GAUGE:0:U