summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2017-05-04 00:39:35 +0300
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2017-05-04 00:39:35 +0300
commitb689036d47ee0004f1ac11e888073d0557e28ca9 (patch)
treed416d9ed6d71bed8b744e957c9dc973ee7ff88db
parentc93f4240e3a65e3f63b3f82ed651e4caae106b9d (diff)
operational statsd with custom apps
-rw-r--r--profile/statsd-stress.c15
-rw-r--r--src/backends.c32
-rw-r--r--src/inlined.h76
-rw-r--r--src/log.h7
-rw-r--r--src/rrdpush.c4
-rw-r--r--src/socket.c105
-rw-r--r--src/socket.h7
-rw-r--r--src/statsd.c47
-rw-r--r--src/web_client.c4
9 files changed, 236 insertions, 61 deletions
diff --git a/profile/statsd-stress.c b/profile/statsd-stress.c
index aebe58f6f8..05a7f5de3c 100644
--- a/profile/statsd-stress.c
+++ b/profile/statsd-stress.c
@@ -59,8 +59,8 @@ static void *report_thread(void *__data) {
return NULL;
}
-#define STATSD_METRIC_TYPES 6
-char *types[STATSD_METRIC_TYPES] = {"g", "c", "m", "ms", "h", "s"};
+char *types[] = {"g", "c", "m", "ms", "h", "s", NULL};
+// char *types[] = {"g", "c", "C", "h", "ms", NULL}; // brubeck compatible
static void *spam_thread(void *__data) {
struct thread_data *data = (struct thread_data *)__data;
@@ -73,12 +73,17 @@ static void *spam_thread(void *__data) {
char **packets = malloc(sizeof(char *) * metrics);
size_t i, *lengths = malloc(sizeof(size_t) * metrics);
+ size_t t;
- for(i = 0; i < metrics ;i++) {
- lengths[i] = sprintf(packet, "github.test.packet.%zu.%zu:%zu.%zu|%s", data->id, i, myrand(metrics), myrand(metrics), types[myrand(STATSD_METRIC_TYPES)]);
+ for(i = 0, t = 0; i < metrics ;i++, t++) {
+ if(!types[t]) t = 0;
+ char *type = types[t];
+
+ lengths[i] = sprintf(packet, "stress.%s.t%zu.m%zu:%zu|%s", type, data->id, i, myrand(metrics), type);
packets[i] = strdup(packet);
- // printf("packet %d, of length %zu: '%s'\n", i, lengths[i], packets[i]);
+ // printf("packet %zu, of length %zu: '%s'\n", i, lengths[i], packets[i]);
}
+ //printf("\n");
for (;;) {
for(i = 0; i < metrics ;i++) {
diff --git a/src/backends.c b/src/backends.c
index 2d9a09589e..f38a9e652e 100644
--- a/src/backends.c
+++ b/src/backends.c
@@ -401,13 +401,13 @@ void *backends_main(void *ptr) {
int (*backend_request_formatter)(BUFFER *, const char *, RRDHOST *, const char *, RRDSET *, RRDDIM *, time_t, time_t, uint32_t) = NULL;
int (*backend_response_checker)(BUFFER *) = NULL;
- info("BACKEND thread created with task id %d", gettid());
+ info("BACKEND: thread created with task id %d", gettid());
if(pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) != 0)
- error("Cannot set pthread cancel type to DEFERRED.");
+ error("BACKEND: cannot set pthread cancel type to DEFERRED.");
if(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) != 0)
- error("Cannot set pthread cancel state to ENABLE.");
+ error("BACKEND: cannot set pthread cancel state to ENABLE.");
// ------------------------------------------------------------------------
// collect configuration options
@@ -444,12 +444,12 @@ void *backends_main(void *ptr) {
options |= BACKEND_SOURCE_DATA_SUM;
}
else {
- error("Invalid data source method '%s' for backend given. Disabling backed.", source);
+ error("BACKEND: invalid data source method '%s' for backend given. Disabling backed.", source);
goto cleanup;
}
if(timeoutms < 1) {
- error("BACKED invalid timeout %ld ms given. Assuming %d ms.", timeoutms, frequency * 2 * 1000);
+ error("BACKEND: invalid timeout %ld ms given. Assuming %d ms.", timeoutms, frequency * 2 * 1000);
timeoutms = frequency * 2 * 1000;
}
timeout.tv_sec = (timeoutms * 1000) / 1000000;
@@ -493,12 +493,12 @@ void *backends_main(void *ptr) {
}
else {
- error("Unknown backend type '%s'", type);
+ error("BACKEND: Unknown backend type '%s'", type);
goto cleanup;
}
if(backend_request_formatter == NULL || backend_response_checker == NULL) {
- error("backend is misconfigured - disabling it.");
+ error("BACKEND: backend is misconfigured - disabling it.");
goto cleanup;
}
@@ -560,7 +560,7 @@ void *backends_main(void *ptr) {
// ------------------------------------------------------------------------
// prepare the backend main loop
- info("BACKEND configured ('%s' on '%s' sending '%s' data, every %d seconds, as host '%s', with prefix '%s')", type, destination, source, frequency, hostname, prefix);
+ info("BACKEND: configured ('%s' on '%s' sending '%s' data, every %d seconds, as host '%s', with prefix '%s')", type, destination, source, frequency, hostname, prefix);
usec_t step_ut = frequency * USEC_PER_SEC;
time_t after = now_realtime_sec();
@@ -582,7 +582,7 @@ void *backends_main(void *ptr) {
int pthreadoldcancelstate;
if(unlikely(pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &pthreadoldcancelstate) != 0))
- error("Cannot set pthread cancel state to DISABLE.");
+ error("BACKEND: cannot set pthread cancel state to DISABLE.");
size_t count_hosts = 0;
size_t count_charts_total = 0;
@@ -634,7 +634,7 @@ void *backends_main(void *ptr) {
debug(D_BACKEND, "BACKEND: buffer has %zu bytes, added metrics for %zu dimensions, of %zu charts, from %zu hosts", buffer_strlen(b), count_dims_total, count_charts_total, count_hosts);
if(unlikely(pthread_setcancelstate(pthreadoldcancelstate, NULL) != 0))
- error("Cannot set pthread cancel state to RESTORE (%d).", pthreadoldcancelstate);
+ error("BACKEND: cannot set pthread cancel state to RESTORE (%d).", pthreadoldcancelstate);
// ------------------------------------------------------------------------
@@ -679,14 +679,14 @@ void *backends_main(void *ptr) {
chart_receptions++;
}
else if(r == 0) {
- error("Backend '%s' closed the socket", destination);
+ error("BACKEND: '%s' closed the socket", destination);
close(sock);
sock = -1;
}
else {
// failed to receive data
if(errno != EAGAIN && errno != EWOULDBLOCK) {
- error("Cannot receive data from backend '%s'.", destination);
+ error("BACKEND: cannot receive data from backend '%s'.", destination);
}
}
}
@@ -738,7 +738,7 @@ void *backends_main(void *ptr) {
}
else {
// oops! we couldn't send (all or some of the) data
- error("Failed to write data to database backend '%s'. Willing to write %zu bytes, wrote %zd bytes. Will re-connect.", destination, len, written);
+ error("BACKEND: failed to write data to database backend '%s'. Willing to write %zu bytes, wrote %zd bytes. Will re-connect.", destination, len, written);
chart_transmission_failures++;
if(written != -1)
@@ -753,7 +753,7 @@ void *backends_main(void *ptr) {
}
}
else {
- error("Failed to update database backend '%s'", destination);
+ error("BACKEND: failed to update database backend '%s'", destination);
chart_transmission_failures++;
// increment the counter we check for data loss
@@ -763,7 +763,7 @@ void *backends_main(void *ptr) {
if(failures > buffer_on_failures) {
// too bad! we are going to lose data
chart_lost_bytes += buffer_strlen(b);
- error("Reached %d backend failures. Flushing buffers to protect this host - this results in data loss on back-end server '%s'", failures, destination);
+ error("BACKEND: reached %d backend failures. Flushing buffers to protect this host - this results in data loss on back-end server '%s'", failures, destination);
buffer_flush(b);
failures = 0;
chart_data_lost_events++;
@@ -821,7 +821,7 @@ cleanup:
buffer_free(b);
buffer_free(response);
- info("BACKEND thread exiting");
+ info("BACKEND: thread exiting");
static_thread->enabled = 0;
pthread_exit(NULL);
diff --git a/src/inlined.h b/src/inlined.h
index 0dc11c9509..858ba31abc 100644
--- a/src/inlined.h
+++ b/src/inlined.h
@@ -123,6 +123,82 @@ static inline unsigned long long str2ull(const char *s) {
return n;
}
+static inline long long str2ll(const char *s, char **endptr) {
+ int negative = 0;
+
+ if(unlikely(*s == '-')) {
+ s++;
+ negative = 1;
+ }
+ else if(unlikely(*s == '+'))
+ s++;
+
+ long long n = 0;
+ char c;
+ for(c = *s; c >= '0' && c <= '9' ; c = *(++s)) {
+ n *= 10;
+ n += c - '0';
+ }
+
+ if(unlikely(endptr))
+ *endptr = (char *)s;
+
+ if(unlikely(negative))
+ return -n;
+ else
+ return n;
+}
+
+static inline long double str2ld(const char *s, char **endptr) {
+ int negative = 0;
+ const char *start = s;
+ unsigned long long integer_part = 0;
+ unsigned long decimal_part = 0;
+ size_t decimal_digits = 0;
+
+ if(unlikely(*s == '-')) {
+ s++;
+ negative = 1;
+ }
+ else if(unlikely(*s == '+'))
+ s++;
+
+ while (*s >= '0' && *s <= '9') {
+ integer_part = (integer_part * 10) + (*s - '0');
+ s++;
+ }
+
+ if(unlikely(*s == '.')) {
+ decimal_part = 0;
+ s++;
+
+ while (*s >= '0' && *s <= '9') {
+ decimal_part = (decimal_part * 10) + (*s - '0');
+ s++;
+ decimal_digits++;
+ }
+ }
+
+ if(unlikely(*s == 'e' || *s == 'E'))
+ return strtold(start, endptr);
+
+ if(unlikely(endptr))
+ *endptr = (char *)s;
+
+ if(unlikely(negative)) {
+ if(unlikely(decimal_digits))
+ return -((long double)integer_part + (long double)decimal_part / powl(10.0, decimal_digits));
+ else
+ return -((long double)integer_part);
+ }
+ else {
+ if(unlikely(decimal_digits))
+ return (long double)integer_part + (long double)decimal_part / powl(10.0, decimal_digits);
+ else
+ return (long double)integer_part;
+ }
+}
+
#ifdef NETDATA_STRCMP_OVERRIDE
#ifdef strcmp
#undef strcmp
diff --git a/src/log.h b/src/log.h
index 478f5c803a..dacaaf8a53 100644
--- a/src/log.h
+++ b/src/log.h
@@ -59,10 +59,17 @@ extern int error_log_limit(int reset);
extern void open_all_log_files();
extern void reopen_all_log_files();
+static inline void debug_dummy(void) {}
+
#define error_log_limit_reset() do { error_log_throttle_period = error_log_throttle_period_backup; error_log_limit(1); } while(0)
#define error_log_limit_unlimited() do { error_log_throttle_period = 0; } while(0)
+#ifdef NETDATA_INTERNAL_CHECKS
#define debug(type, args...) do { if(unlikely(debug_flags & type)) debug_int(__FILE__, __FUNCTION__, __LINE__, ##args); } while(0)
+#else
+#define debug(type, args...) debug_dummy()
+#endif
+
#define info(args...) info_int(__FILE__, __FUNCTION__, __LINE__, ##args)
#define infoerr(args...) error_int("INFO", __FILE__, __FUNCTION__, __LINE__, ##args)
#define error(args...) error_int("ERROR", __FILE__, __FUNCTION__, __LINE__, ##args)
diff --git a/src/rrdpush.c b/src/rrdpush.c
index 46e2deb29e..bfe128ec3a 100644
--- a/src/rrdpush.c
+++ b/src/rrdpush.c
@@ -339,7 +339,7 @@ void *rrdpush_sender_thread(void *ptr) {
info("STREAM %s [send to %s]: established communication - sending metrics...", host->hostname, connected_to);
- if(fcntl(host->rrdpush_socket, F_SETFL, O_NONBLOCK) < 0)
+ if(sock_setnonblock(host->rrdpush_socket) < 0)
error("STREAM %s [send to %s]: cannot set non-blocking mode for socket.", host->hostname, connected_to);
rrdpush_sender_thread_data_flush(host);
@@ -560,7 +560,7 @@ int rrdpush_receive(int fd, const char *key, const char *hostname, const char *m
}
// remove the non-blocking flag from the socket
- if(fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~O_NONBLOCK) == -1)
+ if(sock_delnonblock(fd) < 0)
error("STREAM %s [receive from [%s]:%s]: cannot remove the non-blocking flag from socket %d", host->hostname, client_ip, client_port, fd);
// convert the socket to a FILE *
diff --git a/src/socket.c b/src/socket.c
index 2fbcf86d0b..a72f3c99ce 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -1,12 +1,87 @@
#include "common.h"
// --------------------------------------------------------------------------------------------------------------------
+// various library calls
+
+#ifdef __gnu_linux__
+#define LARGE_SOCK_SIZE 33554431 // don't ask why - I found it at brubeck source - I guess it is just a large number
+#else
+#define LARGE_SOCK_SIZE 4096
+#endif
+
+int sock_setnonblock(int fd) {
+ int flags;
+
+ flags = fcntl(fd, F_GETFL);
+ flags |= O_NONBLOCK;
+
+ int ret = fcntl(fd, F_SETFL, flags);
+ if(ret < 0)
+ error("Failed to set O_NONBLOCK on socket %d", fd);
+
+ return ret;
+}
+
+int sock_delnonblock(int fd) {
+ int flags;
+
+ flags = fcntl(fd, F_GETFL);
+ flags &= ~O_NONBLOCK;
+
+ int ret = fcntl(fd, F_SETFL, flags);
+ if(ret < 0)
+ error("Failed to remove O_NONBLOCK on socket %d", fd);
+
+ return ret;
+}
+
+int sock_setreuse(int fd, int reuse) {
+ int ret = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse));
+
+ if(ret == -1)
+ error("Failed to set SO_REUSEADDR on socket %d", fd);
+
+ return ret;
+}
+
+int sock_setreuse_port(int fd, int reuse) {
+ int ret = -1;
+#ifdef SO_REUSEPORT
+ ret = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &reuse, sizeof(reuse));
+#endif
+ if(ret == -1)
+ error("failed to set SO_REUSEPORT on socket %d", fd);
+
+ return ret;
+}
+
+int sock_enlarge_in(int fd) {
+ int ret, bs = LARGE_SOCK_SIZE;
+
+ ret = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &bs, sizeof(bs));
+
+ if(ret == -1)
+ error("Failed to set SO_RCVBUF on socket %d", fd);
+
+ return ret;
+}
+
+int sock_enlarge_out(int fd) {
+ int ret, bs = LARGE_SOCK_SIZE;
+ ret = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &bs, sizeof(bs));
+
+ if(ret == -1)
+ error("Failed to set SO_SNDBUF on socket %d", fd);
+
+ return ret;
+}
+
+
+// --------------------------------------------------------------------------------------------------------------------
// listening sockets
int create_listen_socket4(int socktype, const char *ip, int port, int listen_backlog) {
int sock;
- int sockopt = 1;
- int nonblock = 1;
debug(D_LISTENER, "LISTENER: IPv4 creating new listening socket on ip '%s' port %d, socktype %d", ip, port, socktype);
@@ -16,13 +91,10 @@ int create_listen_socket4(int socktype, const char *ip, int port, int listen_bac
return -1;
}
- /* avoid "address already in use" */
- if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void*)&sockopt, sizeof(sockopt)) != 0)
- error("LISTENER: Cannot set SO_REUSEADDR on ip '%s' port %d, socktype %d.", ip, port, socktype);
-
- /* set non-blocking mode */
- if(ioctl(sock, FIONBIO, (char *)&nonblock))
- error("LISTENER: Cannot set FIONBIO on ip '%s' port %d, socktype %d.", ip, port, socktype);
+ sock_setreuse(sock, 1);
+ sock_setreuse_port(sock, 1);
+ sock_setnonblock(sock);
+ sock_enlarge_in(sock);
struct sockaddr_in name;
memset(&name, 0, sizeof(struct sockaddr_in));
@@ -53,10 +125,8 @@ int create_listen_socket4(int socktype, const char *ip, int port, int listen_bac
}
int create_listen_socket6(int socktype, uint32_t scope_id, const char *ip, int port, int listen_backlog) {
- int sock = -1;
- int sockopt = 1;
+ int sock;
int ipv6only = 1;
- int nonblock = 1;
debug(D_LISTENER, "LISTENER: IPv6 creating new listening socket on ip '%s' port %d, socktype %d", ip, port, socktype);
@@ -66,13 +136,10 @@ int create_listen_socket6(int socktype, uint32_t scope_id, const char *ip, int p
return -1;
}
- /* avoid "address already in use" */
- if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void*)&sockopt, sizeof(sockopt)) != 0)
- error("LISTENER: Cannot set SO_REUSEADDR on ip '%s' port %d, socktype %d.", ip, port, socktype);
-
- /* set non-blocking mode */
- if(ioctl(sock, FIONBIO, (char *)&nonblock))
- error("LISTENER: Cannot set FIONBIO on ip '%s' port %d, socktype %d.", ip, port, socktype);
+ sock_setreuse(sock, 1);
+ sock_setreuse_port(sock, 1);
+ sock_setnonblock(sock);
+ sock_enlarge_in(sock);
/* IPv6 only */
if(setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&ipv6only, sizeof(ipv6only)) != 0)
diff --git a/src/socket.h b/src/socket.h
index 5f6f7d3376..bb95347ab5 100644
--- a/src/socket.h
+++ b/src/socket.h
@@ -27,6 +27,13 @@ extern int connect_to_one_of(const char *destination, int default_port, struct t
extern ssize_t recv_timeout(int sockfd, void *buf, size_t len, int flags, int timeout);
extern ssize_t send_timeout(int sockfd, void *buf, size_t len, int flags, int timeout);
+extern int sock_setnonblock(int fd);
+extern int sock_delnonblock(int fd);
+extern int sock_setreuse(int fd, int reuse);
+extern int sock_setreuse_port(int fd, int reuse);
+extern int sock_enlarge_in(int fd);
+extern int sock_enlarge_out(int fd);
+
extern int accept_socket(int fd, int flags, char *client_ip, size_t ipsize, char *client_port, size_t portsize);
#ifndef HAVE_ACCEPT4
diff --git a/src/statsd.c b/src/statsd.c
index 4c2d7e46c6..cfd09fbba0 100644
--- a/src/statsd.c
+++ b/src/statsd.c
@@ -3,7 +3,6 @@
#define STATSD_CHART_PREFIX "statsd"
#define STATSD_CHART_PRIORITY 90000
-
// --------------------------------------------------------------------------------------
// #define STATSD_MULTITHREADED 1
@@ -145,18 +144,17 @@ static int statsd_metric_compare(void* a, void* b);
// --------------------------------------------------------------------------------------------------------------------
// synthetic charts
-typedef struct statsd_app_chart_dim {
+typedef struct statsd_app_chart_dimension {
const char *name;
const char *metric;
uint32_t metric_hash;
- const char *options;
collected_number multiplier;
collected_number divider;
STATSD_INDEX *index;
STATSD_METRIC *m;
RRDDIM *rd;
- struct statsd_app_chart_dim *next;
+ struct statsd_app_chart_dimension *next;
} STATSD_APP_CHART_DIM;
typedef struct statsd_app_chart {
@@ -318,7 +316,7 @@ static inline STATSD_METRIC *stasd_metric_index_find(STATSD_INDEX *index, const
}
static inline STATSD_METRIC *statsd_find_or_add_metric(STATSD_INDEX *index, const char *name, STATSD_METRIC_TYPE type) {
- debug(D_STATSD, "finding or adding metric '%s' under '%s'", name, index->name);
+ debug(D_STATSD, "searching for metric '%s' under '%s'", name, index->name);
uint32_t hash = simple_hash(name);
@@ -365,8 +363,8 @@ static inline long double statsd_parse_float(const char *v, long double def) {
if(likely(v && *v)) {
char *e = NULL;
- value = strtold(v, &e);
- if(e && *e)
+ value = str2ld(v, &e);
+ if(unlikely(e && *e))
error("STATSD: excess data '%s' after value '%s'", e, v);
}
@@ -378,8 +376,8 @@ static inline long long statsd_parse_int(const char *v, long long def) {
if(likely(v && *v)) {
char *e = NULL;
- value = strtoll(v, &e, 10);
- if(e && *e)
+ value = str2ll(v, &e);
+ if(unlikely(e && *e))
error("STATSD: excess data '%s' after value '%s'", e, v);
}
@@ -406,7 +404,7 @@ static inline void statsd_process_gauge(STATSD_METRIC *m, const char *value, con
statsd_reset_metric(m);
}
- if(*value == '+' || *value == '-')
+ if(unlikely(*value == '+' || *value == '-'))
m->gauge.value += statsd_parse_float(value, 1.0) / statsd_parse_float(sampling, 1.0);
else
m->gauge.value = statsd_parse_float(value, 1.0) / statsd_parse_float(sampling, 1.0);
@@ -442,7 +440,7 @@ static inline void statsd_process_histogram(STATSD_METRIC *m, const char *value,
statsd_reset_metric(m);
}
- if(m->histogram.ext->used == m->histogram.ext->size) {
+ if(unlikely(m->histogram.ext->used == m->histogram.ext->size)) {
netdata_mutex_lock(&m->histogram.mutex);
m->histogram.ext->size += statsd.histogram_increase_step;
m->histogram.ext = reallocz(m->histogram.ext, sizeof(STATSD_METRIC_HISTOGRAM_EXTENSIONS) + (sizeof(long double) * m->histogram.ext->size));
@@ -1080,15 +1078,14 @@ int statsd_readfile(const char *path, const char *filename) {
chart->chart_type = rrdset_type_id(value);
}
else if (!strcmp(name, "dimension")) {
- // metric [name [multiplier [divider [options]]]
- char *words[5];
- pluginsd_split_words(value, words, 5);
+ // metric [name [multiplier [divider]]]
+ char *words[4];
+ pluginsd_split_words(value, words, 4);
char *metric_name = words[0];
char *dim_name = words[1];
char *multipler = words[2];
char *divider = words[3];
- char *options = words[4];
STATSD_APP_CHART_DIM *dim = callocz(sizeof(STATSD_APP_CHART_DIM), 1);
dim->next = chart->dimensions;
@@ -1101,7 +1098,6 @@ int statsd_readfile(const char *path, const char *filename) {
dim->name = strdupz((dim_name && *dim_name)?dim_name:metric_name);
dim->multiplier = (multipler && *multipler)?str2l(multipler):1;
dim->divider = (divider && *divider)?str2l(divider):1;
- dim->options = (options && *options)?strdupz(options):NULL;
if(!dim->multiplier) {
error("STATSD: invalid multiplier value '%s' at line %zu of file '%s/%s'. Using 1.", multipler, line, path, filename);
@@ -1233,6 +1229,8 @@ static inline RRDSET *statsd_private_rrdset_create(
}
static inline void statsd_private_chart_gauge(STATSD_METRIC *m) {
+ debug(D_STATSD, "updating private chart for gauge metric '%s'", m->name);
+
if(unlikely(!m->st)) {
char type[RRD_ID_LENGTH_MAX + 1], id[RRD_ID_LENGTH_MAX + 1];
statsd_get_metric_type_and_id(m, type, id, "gauge", RRD_ID_LENGTH_MAX);
@@ -1267,6 +1265,8 @@ static inline void statsd_private_chart_gauge(STATSD_METRIC *m) {
}
static inline void statsd_private_chart_counter_or_meter(STATSD_METRIC *m, const char *dim, const char *family) {
+ debug(D_STATSD, "updating private chart for %s metric '%s'", dim, m->name);
+
if(unlikely(!m->st)) {
char type[RRD_ID_LENGTH_MAX + 1], id[RRD_ID_LENGTH_MAX + 1];
statsd_get_metric_type_and_id(m, type, id, dim, RRD_ID_LENGTH_MAX);
@@ -1301,6 +1301,8 @@ static inline void statsd_private_chart_counter_or_meter(STATSD_METRIC *m, const
}
static inline void statsd_private_chart_set(STATSD_METRIC *m) {
+ debug(D_STATSD, "updating private chart for set metric '%s'", m->name);
+
if(unlikely(!m->st)) {
char type[RRD_ID_LENGTH_MAX + 1], id[RRD_ID_LENGTH_MAX + 1];
statsd_get_metric_type_and_id(m, type, id, "set", RRD_ID_LENGTH_MAX);
@@ -1335,6 +1337,8 @@ static inline void statsd_private_chart_set(STATSD_METRIC *m) {
}
static inline void statsd_private_chart_timer_or_histogram(STATSD_METRIC *m, const char *dim, const char *family, const char *units) {
+ debug(D_STATSD, "updating private chart for %s metric '%s'", dim, m->name);
+
if(unlikely(!m->st)) {
char type[RRD_ID_LENGTH_MAX + 1], id[RRD_ID_LENGTH_MAX + 1];
statsd_get_metric_type_and_id(m, type, id, dim, RRD_ID_LENGTH_MAX);
@@ -1382,6 +1386,8 @@ static inline void statsd_private_chart_timer_or_histogram(STATSD_METRIC *m, con
// statsd flush metrics
static inline void statsd_flush_gauge(STATSD_METRIC *m) {
+ debug(D_STATSD, "flushing gauge metric '%s'", m->name);
+
int updated = 0;
if(m->count && !m->reset)
@@ -1394,6 +1400,8 @@ static inline void statsd_flush_gauge(STATSD_METRIC *m) {
}
static inline void statsd_flush_counter_or_meter(STATSD_METRIC *m, const char *dim, const char *family) {
+ debug(D_STATSD, "flushing %s metric '%s'", dim, m->name);
+
int updated = 0;
if(m->count && !m->reset) {
@@ -1417,6 +1425,8 @@ static inline void statsd_flush_meter(STATSD_METRIC *m) {
}
static inline void statsd_flush_set(STATSD_METRIC *m) {
+ debug(D_STATSD, "flushing set metric '%s'", m->name);
+
int updated = 0;
if(m->count && !m->reset) {
@@ -1431,6 +1441,8 @@ static inline void statsd_flush_set(STATSD_METRIC *m) {
}
static inline void statsd_flush_timer_or_histogram(STATSD_METRIC *m, const char *dim, const char *family, const char *units) {
+ debug(D_STATSD, "flushing %s metric '%s'", dim, m->name);
+
int updated = 0;
netdata_mutex_lock(&m->histogram.mutex);
@@ -1472,6 +1484,7 @@ static inline void check_if_metric_is_for_app(STATSD_INDEX *index, STATSD_METRIC
STATSD_APP *app;
for(app = statsd.apps; app ;app = app->next) {
if(unlikely(simple_pattern_matches(app->metrics, m->name))) {
+ debug(D_STATSD, "metric '%s' matches app '%s'", m->name, app->name);
// the metric should get the options from the app
@@ -1494,7 +1507,7 @@ static inline void check_if_metric_is_for_app(STATSD_INDEX *index, STATSD_METRIC
for(dim = chart->dimensions; dim ; dim = dim->next) {
if(!dim->m && dim->metric_hash == m->hash && !strcmp(dim->metric, m->name)) {
// we have a match - this metric should be linked to this dimension
- debug(D_STATSD, "new metric '%s' is now linked with app '%s', chart '%s', dimension '%s'", m->name, app->name, chart->id, dim->name);
+ debug(D_STATSD, "metric '%s' linked with app '%s', chart '%s', dimension '%s'", m->name, app->name, chart->id, dim->name);
dim->m = m;
chart->dimensions_linked_count++;
}
diff --git a/src/web_client.c b/src/web_client.c
index 407502aa84..7da080705f 100644
--- a/src/web_client.c
+++ b/src/web_client.c
@@ -355,8 +355,8 @@ int mysendfile(struct web_client *w, char *filename) {
return 404;
}
}
- if(fcntl(w->ifd, F_SETFL, O_NONBLOCK) < 0)
- error("%llu: Cannot set O_NONBLOCK on file '%s'.", w->id, webfilename);
+
+ sock_setnonblock(w->ifd);
// pick a Content-Type for the file
if(strstr(filename, ".html") != NULL) w->response.data->contenttype = CT_TEXT_HTML;