operational statsd with custom apps
Costa Tsaousis (ktsaou) committed
May 4, 2017 at 00:39 UTC
b689036d47ee0004f1ac11e888073d0557e28ca9
9 files changed
+236
-61
profile/statsd-stress.c
+10
-5
@@ -59,8 +59,8 @@ static void *report_thread(void *__data) {
59
return NULL;
60
}
61
62
-#define STATSD_METRIC_TYPES 6
63
-char *types[STATSD_METRIC_TYPES] = {"g", "c", "m", "ms", "h", "s"};
62
+char *types[] = {"g", "c", "m", "ms", "h", "s", NULL};
63
+// char *types[] = {"g", "c", "C", "h", "ms", NULL}; // brubeck compatible
64
65
static void *spam_thread(void *__data) {
66
struct thread_data *data = (struct thread_data *)__data;
@@ -73,12 +73,17 @@ static void *spam_thread(void *__data) {
73
74
char **packets = malloc(sizeof(char *) * metrics);
75
size_t i, *lengths = malloc(sizeof(size_t) * metrics);
76
+ size_t t;
77
77
- for(i = 0; i < metrics ;i++) {
78
- lengths[i] = sprintf(packet, "github.test.packet.%zu.%zu:%zu.%zu|%s", data->id, i, myrand(metrics), myrand(metrics), types[myrand(STATSD_METRIC_TYPES)]);
78
+ for(i = 0, t = 0; i < metrics ;i++, t++) {
79
+ if(!types[t]) t = 0;
80
+ char *type = types[t];
81
+
82
+ lengths[i] = sprintf(packet, "stress.%s.t%zu.m%zu:%zu|%s", type, data->id, i, myrand(metrics), type);
83
packets[i] = strdup(packet);
80
- // printf("packet %d, of length %zu: '%s'\n", i, lengths[i], packets[i]);
84
+ // printf("packet %zu, of length %zu: '%s'\n", i, lengths[i], packets[i]);
85
}
86
+ //printf("\n");
87
88
for (;;) {
89
for(i = 0; i < metrics ;i++) {
src/backends.c
+16
-16
@@ -401,13 +401,13 @@ void *backends_main(void *ptr) {
401
int (*backend_request_formatter)(BUFFER *, const char *, RRDHOST *, const char *, RRDSET *, RRDDIM *, time_t, time_t, uint32_t) = NULL;
402
int (*backend_response_checker)(BUFFER *) = NULL;
403
404
- info("BACKEND thread created with task id %d", gettid());
404
+ info("BACKEND: thread created with task id %d", gettid());
405
406
if(pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) != 0)
407
- error("Cannot set pthread cancel type to DEFERRED.");
407
+ error("BACKEND: cannot set pthread cancel type to DEFERRED.");
408
409
if(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) != 0)
410
- error("Cannot set pthread cancel state to ENABLE.");
410
+ error("BACKEND: cannot set pthread cancel state to ENABLE.");
411
412
// ------------------------------------------------------------------------
413
// collect configuration options
@@ -444,12 +444,12 @@ void *backends_main(void *ptr) {
444
options |= BACKEND_SOURCE_DATA_SUM;
445
}
446
else {
447
- error("Invalid data source method '%s' for backend given. Disabling backed.", source);
447
+ error("BACKEND: invalid data source method '%s' for backend given. Disabling backed.", source);
448
goto cleanup;
449
}
450
451
if(timeoutms < 1) {
452
- error("BACKED invalid timeout %ld ms given. Assuming %d ms.", timeoutms, frequency * 2 * 1000);
452
+ error("BACKEND: invalid timeout %ld ms given. Assuming %d ms.", timeoutms, frequency * 2 * 1000);
453
timeoutms = frequency * 2 * 1000;
454
}
455
timeout.tv_sec = (timeoutms * 1000) / 1000000;
@@ -493,12 +493,12 @@ void *backends_main(void *ptr) {
493
494
}
495
else {
496
- error("Unknown backend type '%s'", type);
496
+ error("BACKEND: Unknown backend type '%s'", type);
497
goto cleanup;
498
}
499
500
if(backend_request_formatter == NULL || backend_response_checker == NULL) {
501
- error("backend is misconfigured - disabling it.");
501
+ error("BACKEND: backend is misconfigured - disabling it.");
502
goto cleanup;
503
}
504
@@ -560,7 +560,7 @@ void *backends_main(void *ptr) {
560
// ------------------------------------------------------------------------
561
// prepare the backend main loop
562
563
- info("BACKEND configured ('%s' on '%s' sending '%s' data, every %d seconds, as host '%s', with prefix '%s')", type, destination, source, frequency, hostname, prefix);
563
+ info("BACKEND: configured ('%s' on '%s' sending '%s' data, every %d seconds, as host '%s', with prefix '%s')", type, destination, source, frequency, hostname, prefix);
564
565
usec_t step_ut = frequency * USEC_PER_SEC;
566
time_t after = now_realtime_sec();
@@ -582,7 +582,7 @@ void *backends_main(void *ptr) {
582
int pthreadoldcancelstate;
583
584
if(unlikely(pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &pthreadoldcancelstate) != 0))
585
- error("Cannot set pthread cancel state to DISABLE.");
585
+ error("BACKEND: cannot set pthread cancel state to DISABLE.");
586
587
size_t count_hosts = 0;
588
size_t count_charts_total = 0;
@@ -634,7 +634,7 @@ void *backends_main(void *ptr) {
634
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);
635
636
if(unlikely(pthread_setcancelstate(pthreadoldcancelstate, NULL) != 0))
637
- error("Cannot set pthread cancel state to RESTORE (%d).", pthreadoldcancelstate);
637
+ error("BACKEND: cannot set pthread cancel state to RESTORE (%d).", pthreadoldcancelstate);
638
639
// ------------------------------------------------------------------------
640
@@ -679,14 +679,14 @@ void *backends_main(void *ptr) {
679
chart_receptions++;
680
}
681
else if(r == 0) {
682
- error("Backend '%s' closed the socket", destination);
682
+ error("BACKEND: '%s' closed the socket", destination);
683
close(sock);
684
sock = -1;
685
}
686
else {
687
// failed to receive data
688
if(errno != EAGAIN && errno != EWOULDBLOCK) {
689
- error("Cannot receive data from backend '%s'.", destination);
689
+ error("BACKEND: cannot receive data from backend '%s'.", destination);
690
}
691
}
692
}
@@ -738,7 +738,7 @@ void *backends_main(void *ptr) {
738
}
739
else {
740
// oops! we couldn't send (all or some of the) data
741
- error("Failed to write data to database backend '%s'. Willing to write %zu bytes, wrote %zd bytes. Will re-connect.", destination, len, written);
741
+ error("BACKEND: failed to write data to database backend '%s'. Willing to write %zu bytes, wrote %zd bytes. Will re-connect.", destination, len, written);
742
chart_transmission_failures++;
743
744
if(written != -1)
@@ -753,7 +753,7 @@ void *backends_main(void *ptr) {
753
}
754
}
755
else {
756
- error("Failed to update database backend '%s'", destination);
756
+ error("BACKEND: failed to update database backend '%s'", destination);
757
chart_transmission_failures++;
758
759
// increment the counter we check for data loss
@@ -763,7 +763,7 @@ void *backends_main(void *ptr) {
763
if(failures > buffer_on_failures) {
764
// too bad! we are going to lose data
765
chart_lost_bytes += buffer_strlen(b);
766
- error("Reached %d backend failures. Flushing buffers to protect this host - this results in data loss on back-end server '%s'", failures, destination);
766
+ error("BACKEND: reached %d backend failures. Flushing buffers to protect this host - this results in data loss on back-end server '%s'", failures, destination);
767
buffer_flush(b);
768
failures = 0;
769
chart_data_lost_events++;
@@ -821,7 +821,7 @@ cleanup:
821
buffer_free(b);
822
buffer_free(response);
823
824
- info("BACKEND thread exiting");
824
+ info("BACKEND: thread exiting");
825
826
static_thread->enabled = 0;
827
pthread_exit(NULL);
src/inlined.h
+76
@@ -123,6 +123,82 @@ static inline unsigned long long str2ull(const char *s) {
123
return n;
124
}
125
126
+static inline long long str2ll(const char *s, char **endptr) {
127
+ int negative = 0;
128
+
129
+ if(unlikely(*s == '-')) {
130
+ s++;
131
+ negative = 1;
132
+ }
133
+ else if(unlikely(*s == '+'))
134
+ s++;
135
+
136
+ long long n = 0;
137
+ char c;
138
+ for(c = *s; c >= '0' && c <= '9' ; c = *(++s)) {
139
+ n *= 10;
140
+ n += c - '0';
141
+ }
142
+
143
+ if(unlikely(endptr))
144
+ *endptr = (char *)s;
145
+
146
+ if(unlikely(negative))
147
+ return -n;
148
+ else
149
+ return n;
150
+}
151
+
152
+static inline long double str2ld(const char *s, char **endptr) {
153
+ int negative = 0;
154
+ const char *start = s;
155
+ unsigned long long integer_part = 0;
156
+ unsigned long decimal_part = 0;
157
+ size_t decimal_digits = 0;
158
+
159
+ if(unlikely(*s == '-')) {
160
+ s++;
161
+ negative = 1;
162
+ }
163
+ else if(unlikely(*s == '+'))
164
+ s++;
165
+
166
+ while (*s >= '0' && *s <= '9') {
167
+ integer_part = (integer_part * 10) + (*s - '0');
168
+ s++;
169
+ }
170
+
171
+ if(unlikely(*s == '.')) {
172
+ decimal_part = 0;
173
+ s++;
174
+
175
+ while (*s >= '0' && *s <= '9') {
176
+ decimal_part = (decimal_part * 10) + (*s - '0');
177
+ s++;
178
+ decimal_digits++;
179
+ }
180
+ }
181
+
182
+ if(unlikely(*s == 'e' || *s == 'E'))
183
+ return strtold(start, endptr);
184
+
185
+ if(unlikely(endptr))
186
+ *endptr = (char *)s;
187
+
188
+ if(unlikely(negative)) {
189
+ if(unlikely(decimal_digits))
190
+ return -((long double)integer_part + (long double)decimal_part / powl(10.0, decimal_digits));
191
+ else
192
+ return -((long double)integer_part);
193
+ }
194
+ else {
195
+ if(unlikely(decimal_digits))
196
+ return (long double)integer_part + (long double)decimal_part / powl(10.0, decimal_digits);
197
+ else
198
+ return (long double)integer_part;
199
+ }
200
+}
201
+
202
#ifdef NETDATA_STRCMP_OVERRIDE
203
#ifdef strcmp
204
#undef strcmp
src/log.h
+7
@@ -59,10 +59,17 @@ extern int error_log_limit(int reset);
59
extern void open_all_log_files();
60
extern void reopen_all_log_files();
61
62
+static inline void debug_dummy(void) {}
63
+
64
#define error_log_limit_reset() do { error_log_throttle_period = error_log_throttle_period_backup; error_log_limit(1); } while(0)
65
#define error_log_limit_unlimited() do { error_log_throttle_period = 0; } while(0)
66
67
+#ifdef NETDATA_INTERNAL_CHECKS
68
#define debug(type, args...) do { if(unlikely(debug_flags & type)) debug_int(__FILE__, __FUNCTION__, __LINE__, ##args); } while(0)
69
+#else
70
+#define debug(type, args...) debug_dummy()
71
+#endif
72
+
73
#define info(args...) info_int(__FILE__, __FUNCTION__, __LINE__, ##args)
74
#define infoerr(args...) error_int("INFO", __FILE__, __FUNCTION__, __LINE__, ##args)
75
#define error(args...) error_int("ERROR", __FILE__, __FUNCTION__, __LINE__, ##args)
src/rrdpush.c
+2
-2
@@ -339,7 +339,7 @@ void *rrdpush_sender_thread(void *ptr) {
339
340
info("STREAM %s [send to %s]: established communication - sending metrics...", host->hostname, connected_to);
341
342
- if(fcntl(host->rrdpush_socket, F_SETFL, O_NONBLOCK) < 0)
342
+ if(sock_setnonblock(host->rrdpush_socket) < 0)
343
error("STREAM %s [send to %s]: cannot set non-blocking mode for socket.", host->hostname, connected_to);
344
345
rrdpush_sender_thread_data_flush(host);
@@ -560,7 +560,7 @@ int rrdpush_receive(int fd, const char *key, const char *hostname, const char *m
560
}
561
562
// remove the non-blocking flag from the socket
563
- if(fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~O_NONBLOCK) == -1)
563
+ if(sock_delnonblock(fd) < 0)
564
error("STREAM %s [receive from [%s]:%s]: cannot remove the non-blocking flag from socket %d", host->hostname, client_ip, client_port, fd);
565
566
// convert the socket to a FILE *
src/socket.c
+86
-19
@@ -1,12 +1,87 @@
1
#include "common.h"
2
3
+// --------------------------------------------------------------------------------------------------------------------
4
+// various library calls
5
+
6
+#ifdef __gnu_linux__
7
+#define LARGE_SOCK_SIZE 33554431 // don't ask why - I found it at brubeck source - I guess it is just a large number
8
+#else
9
+#define LARGE_SOCK_SIZE 4096
10
+#endif
11
+
12
+int sock_setnonblock(int fd) {
13
+ int flags;
14
+
15
+ flags = fcntl(fd, F_GETFL);
16
+ flags |= O_NONBLOCK;
17
+
18
+ int ret = fcntl(fd, F_SETFL, flags);
19
+ if(ret < 0)
20
+ error("Failed to set O_NONBLOCK on socket %d", fd);
21
+
22
+ return ret;
23
+}
24
+
25
+int sock_delnonblock(int fd) {
26
+ int flags;
27
+
28
+ flags = fcntl(fd, F_GETFL);
29
+ flags &= ~O_NONBLOCK;
30
+
31
+ int ret = fcntl(fd, F_SETFL, flags);
32
+ if(ret < 0)
33
+ error("Failed to remove O_NONBLOCK on socket %d", fd);
34
+
35
+ return ret;
36
+}
37
+
38
+int sock_setreuse(int fd, int reuse) {
39
+ int ret = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse));
40
+
41
+ if(ret == -1)
42
+ error("Failed to set SO_REUSEADDR on socket %d", fd);
43
+
44
+ return ret;
45
+}
46
+
47
+int sock_setreuse_port(int fd, int reuse) {
48
+ int ret = -1;
49
+#ifdef SO_REUSEPORT
50
+ ret = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &reuse, sizeof(reuse));
51
+#endif
52
+ if(ret == -1)
53
+ error("failed to set SO_REUSEPORT on socket %d", fd);
54
+
55
+ return ret;
56
+}
57
+
58
+int sock_enlarge_in(int fd) {
59
+ int ret, bs = LARGE_SOCK_SIZE;
60
+
61
+ ret = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &bs, sizeof(bs));
62
+
63
+ if(ret == -1)
64
+ error("Failed to set SO_RCVBUF on socket %d", fd);
65
+
66
+ return ret;
67
+}
68
+
69
+int sock_enlarge_out(int fd) {
70
+ int ret, bs = LARGE_SOCK_SIZE;
71
+ ret = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &bs, sizeof(bs));
72
+
73
+ if(ret == -1)
74
+ error("Failed to set SO_SNDBUF on socket %d", fd);
75
+
76
+ return ret;
77
+}
78
+
79
+
80
// --------------------------------------------------------------------------------------------------------------------
81
// listening sockets
82
83
int create_listen_socket4(int socktype, const char *ip, int port, int listen_backlog) {
84
int sock;
8
- int sockopt = 1;
9
- int nonblock = 1;
85
86
debug(D_LISTENER, "LISTENER: IPv4 creating new listening socket on ip '%s' port %d, socktype %d", ip, port, socktype);
87
@@ -16,13 +91,10 @@ int create_listen_socket4(int socktype, const char *ip, int port, int listen_bac
91
return -1;
92
}
93
19
- /* avoid "address already in use" */
20
- if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void*)&sockopt, sizeof(sockopt)) != 0)
21
- error("LISTENER: Cannot set SO_REUSEADDR on ip '%s' port %d, socktype %d.", ip, port, socktype);
22
-
23
- /* set non-blocking mode */
24
- if(ioctl(sock, FIONBIO, (char *)&nonblock))
25
- error("LISTENER: Cannot set FIONBIO on ip '%s' port %d, socktype %d.", ip, port, socktype);
94
+ sock_setreuse(sock, 1);
95
+ sock_setreuse_port(sock, 1);
96
+ sock_setnonblock(sock);
97
+ sock_enlarge_in(sock);
98
99
struct sockaddr_in name;
100
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
125
}
126
127
int create_listen_socket6(int socktype, uint32_t scope_id, const char *ip, int port, int listen_backlog) {
56
- int sock = -1;
57
- int sockopt = 1;
128
+ int sock;
129
int ipv6only = 1;
59
- int nonblock = 1;
130
131
debug(D_LISTENER, "LISTENER: IPv6 creating new listening socket on ip '%s' port %d, socktype %d", ip, port, socktype);
132
@@ -66,13 +136,10 @@ int create_listen_socket6(int socktype, uint32_t scope_id, const char *ip, int p
136
return -1;
137
}
138
69
- /* avoid "address already in use" */
70
- if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void*)&sockopt, sizeof(sockopt)) != 0)
71
- error("LISTENER: Cannot set SO_REUSEADDR on ip '%s' port %d, socktype %d.", ip, port, socktype);
72
-
73
- /* set non-blocking mode */
74
- if(ioctl(sock, FIONBIO, (char *)&nonblock))
75
- error("LISTENER: Cannot set FIONBIO on ip '%s' port %d, socktype %d.", ip, port, socktype);
139
+ sock_setreuse(sock, 1);
140
+ sock_setreuse_port(sock, 1);
141
+ sock_setnonblock(sock);
142
+ sock_enlarge_in(sock);
143
144
/* IPv6 only */
145
if(setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&ipv6only, sizeof(ipv6only)) != 0)
src/socket.h
+7
@@ -27,6 +27,13 @@ extern int connect_to_one_of(const char *destination, int default_port, struct t
27
extern ssize_t recv_timeout(int sockfd, void *buf, size_t len, int flags, int timeout);
28
extern ssize_t send_timeout(int sockfd, void *buf, size_t len, int flags, int timeout);
29
30
+extern int sock_setnonblock(int fd);
31
+extern int sock_delnonblock(int fd);
32
+extern int sock_setreuse(int fd, int reuse);
33
+extern int sock_setreuse_port(int fd, int reuse);
34
+extern int sock_enlarge_in(int fd);
35
+extern int sock_enlarge_out(int fd);
36
+
37
extern int accept_socket(int fd, int flags, char *client_ip, size_t ipsize, char *client_port, size_t portsize);
38
39
#ifndef HAVE_ACCEPT4
src/statsd.c
+30
-17
@@ -3,7 +3,6 @@
3
#define STATSD_CHART_PREFIX "statsd"
4
#define STATSD_CHART_PRIORITY 90000
5
6
-
6
// --------------------------------------------------------------------------------------
7
8
// #define STATSD_MULTITHREADED 1
@@ -145,18 +144,17 @@ static int statsd_metric_compare(void* a, void* b);
144
// --------------------------------------------------------------------------------------------------------------------
145
// synthetic charts
146
148
-typedef struct statsd_app_chart_dim {
147
+typedef struct statsd_app_chart_dimension {
148
const char *name;
149
const char *metric;
150
uint32_t metric_hash;
152
- const char *options;
151
collected_number multiplier;
152
collected_number divider;
153
STATSD_INDEX *index;
154
155
STATSD_METRIC *m;
156
RRDDIM *rd;
159
- struct statsd_app_chart_dim *next;
157
+ struct statsd_app_chart_dimension *next;
158
} STATSD_APP_CHART_DIM;
159
160
typedef struct statsd_app_chart {
@@ -318,7 +316,7 @@ static inline STATSD_METRIC *stasd_metric_index_find(STATSD_INDEX *index, const
316
}
317
318
static inline STATSD_METRIC *statsd_find_or_add_metric(STATSD_INDEX *index, const char *name, STATSD_METRIC_TYPE type) {
321
- debug(D_STATSD, "finding or adding metric '%s' under '%s'", name, index->name);
319
+ debug(D_STATSD, "searching for metric '%s' under '%s'", name, index->name);
320
321
uint32_t hash = simple_hash(name);
322
@@ -365,8 +363,8 @@ static inline long double statsd_parse_float(const char *v, long double def) {
363
364
if(likely(v && *v)) {
365
char *e = NULL;
368
- value = strtold(v, &e);
369
- if(e && *e)
366
+ value = str2ld(v, &e);
367
+ if(unlikely(e && *e))
368
error("STATSD: excess data '%s' after value '%s'", e, v);
369
}
370
@@ -378,8 +376,8 @@ static inline long long statsd_parse_int(const char *v, long long def) {
376
377
if(likely(v && *v)) {
378
char *e = NULL;
381
- value = strtoll(v, &e, 10);
382
- if(e && *e)
379
+ value = str2ll(v, &e);
380
+ if(unlikely(e && *e))
381
error("STATSD: excess data '%s' after value '%s'", e, v);
382
}
383
@@ -406,7 +404,7 @@ static inline void statsd_process_gauge(STATSD_METRIC *m, const char *value, con
404
statsd_reset_metric(m);
405
}
406
409
- if(*value == '+' || *value == '-')
407
+ if(unlikely(*value == '+' || *value == '-'))
408
m->gauge.value += statsd_parse_float(value, 1.0) / statsd_parse_float(sampling, 1.0);
409
else
410
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,
440
statsd_reset_metric(m);
441
}
442
445
- if(m->histogram.ext->used == m->histogram.ext->size) {
443
+ if(unlikely(m->histogram.ext->used == m->histogram.ext->size)) {
444
netdata_mutex_lock(&m->histogram.mutex);
445
m->histogram.ext->size += statsd.histogram_increase_step;
446
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) {
1078
chart->chart_type = rrdset_type_id(value);
1079
}
1080
else if (!strcmp(name, "dimension")) {
1083
- // metric [name [multiplier [divider [options]]]
1084
- char *words[5];
1085
- pluginsd_split_words(value, words, 5);
1081
+ // metric [name [multiplier [divider]]]
1082
+ char *words[4];
1083
+ pluginsd_split_words(value, words, 4);
1084
1085
char *metric_name = words[0];
1086
char *dim_name = words[1];
1087
char *multipler = words[2];
1088
char *divider = words[3];
1091
- char *options = words[4];
1089
1090
STATSD_APP_CHART_DIM *dim = callocz(sizeof(STATSD_APP_CHART_DIM), 1);
1091
dim->next = chart->dimensions;
@@ -1101,7 +1098,6 @@ int statsd_readfile(const char *path, const char *filename) {
1098
dim->name = strdupz((dim_name && *dim_name)?dim_name:metric_name);
1099
dim->multiplier = (multipler && *multipler)?str2l(multipler):1;
1100
dim->divider = (divider && *divider)?str2l(divider):1;
1104
- dim->options = (options && *options)?strdupz(options):NULL;
1101
1102
if(!dim->multiplier) {
1103
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(
1229
}
1230
1231
static inline void statsd_private_chart_gauge(STATSD_METRIC *m) {
1232
+ debug(D_STATSD, "updating private chart for gauge metric '%s'", m->name);
1233
+
1234
if(unlikely(!m->st)) {
1235
char type[RRD_ID_LENGTH_MAX + 1], id[RRD_ID_LENGTH_MAX + 1];
1236
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) {
1265
}
1266
1267
static inline void statsd_private_chart_counter_or_meter(STATSD_METRIC *m, const char *dim, const char *family) {
1268
+ debug(D_STATSD, "updating private chart for %s metric '%s'", dim, m->name);
1269
+
1270
if(unlikely(!m->st)) {
1271
char type[RRD_ID_LENGTH_MAX + 1], id[RRD_ID_LENGTH_MAX + 1];
1272
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
1301
}
1302
1303
static inline void statsd_private_chart_set(STATSD_METRIC *m) {
1304
+ debug(D_STATSD, "updating private chart for set metric '%s'", m->name);
1305
+
1306
if(unlikely(!m->st)) {
1307
char type[RRD_ID_LENGTH_MAX + 1], id[RRD_ID_LENGTH_MAX + 1];
1308
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) {
1337
}
1338
1339
static inline void statsd_private_chart_timer_or_histogram(STATSD_METRIC *m, const char *dim, const char *family, const char *units) {
1340
+ debug(D_STATSD, "updating private chart for %s metric '%s'", dim, m->name);
1341
+
1342
if(unlikely(!m->st)) {
1343
char type[RRD_ID_LENGTH_MAX + 1], id[RRD_ID_LENGTH_MAX + 1];
1344
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
1386
// statsd flush metrics
1387
1388
static inline void statsd_flush_gauge(STATSD_METRIC *m) {
1389
+ debug(D_STATSD, "flushing gauge metric '%s'", m->name);
1390
+
1391
int updated = 0;
1392
1393
if(m->count && !m->reset)
@@ -1394,6 +1400,8 @@ static inline void statsd_flush_gauge(STATSD_METRIC *m) {
1400
}
1401
1402
static inline void statsd_flush_counter_or_meter(STATSD_METRIC *m, const char *dim, const char *family) {
1403
+ debug(D_STATSD, "flushing %s metric '%s'", dim, m->name);
1404
+
1405
int updated = 0;
1406
1407
if(m->count && !m->reset) {
@@ -1417,6 +1425,8 @@ static inline void statsd_flush_meter(STATSD_METRIC *m) {
1425
}
1426
1427
static inline void statsd_flush_set(STATSD_METRIC *m) {
1428
+ debug(D_STATSD, "flushing set metric '%s'", m->name);
1429
+
1430
int updated = 0;
1431
1432
if(m->count && !m->reset) {
@@ -1431,6 +1441,8 @@ static inline void statsd_flush_set(STATSD_METRIC *m) {
1441
}
1442
1443
static inline void statsd_flush_timer_or_histogram(STATSD_METRIC *m, const char *dim, const char *family, const char *units) {
1444
+ debug(D_STATSD, "flushing %s metric '%s'", dim, m->name);
1445
+
1446
int updated = 0;
1447
1448
netdata_mutex_lock(&m->histogram.mutex);
@@ -1472,6 +1484,7 @@ static inline void check_if_metric_is_for_app(STATSD_INDEX *index, STATSD_METRIC
1484
STATSD_APP *app;
1485
for(app = statsd.apps; app ;app = app->next) {
1486
if(unlikely(simple_pattern_matches(app->metrics, m->name))) {
1487
+ debug(D_STATSD, "metric '%s' matches app '%s'", m->name, app->name);
1488
1489
// the metric should get the options from the app
1490
@@ -1494,7 +1507,7 @@ static inline void check_if_metric_is_for_app(STATSD_INDEX *index, STATSD_METRIC
1507
for(dim = chart->dimensions; dim ; dim = dim->next) {
1508
if(!dim->m && dim->metric_hash == m->hash && !strcmp(dim->metric, m->name)) {
1509
// we have a match - this metric should be linked to this dimension
1497
- debug(D_STATSD, "new metric '%s' is now linked with app '%s', chart '%s', dimension '%s'", m->name, app->name, chart->id, dim->name);
1510
+ debug(D_STATSD, "metric '%s' linked with app '%s', chart '%s', dimension '%s'", m->name, app->name, chart->id, dim->name);
1511
dim->m = m;
1512
chart->dimensions_linked_count++;
1513
}
src/web_client.c
+2
-2
@@ -355,8 +355,8 @@ int mysendfile(struct web_client *w, char *filename) {
355
return 404;
356
}
357
}
358
- if(fcntl(w->ifd, F_SETFL, O_NONBLOCK) < 0)
359
- error("%llu: Cannot set O_NONBLOCK on file '%s'.", w->id, webfilename);
358
+
359
+ sock_setnonblock(w->ifd);
360
361
// pick a Content-Type for the file
362
if(strstr(filename, ".html") != NULL) w->response.data->contenttype = CT_TEXT_HTML;