@cryptotaxi247 / netdata-1 / commits / 82abfe573

always read all statsd variables, even if statsd is disabled

Costa Tsaousis (ktsaou) committed Apr 30, 2017 at 13:47 UTC 82abfe573f47c0cc6581b8d4e075e9c9c871ea2f
1 file changed +22 -8
src/statsd.c
+22 -8
@@ -1175,8 +1175,10 @@ void *statsd_main(void *ptr) {
1175 if(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) != 0)
1176 error("Cannot set pthread cancel state to ENABLE.");
1177
1178 + // ----------------------------------------------------------------------------------------------------------------
1179 + // statsd configuration
1180 +
1181 statsd.enabled = config_get_boolean(CONFIG_SECTION_STATSD, "enabled", statsd.enabled);
1179 - if(!statsd.enabled) return NULL;
1182
1183 statsd.update_every = default_rrd_update_every;
1184 statsd.update_every = (int)config_get_number(CONFIG_SECTION_STATSD, "update every (flushInterval)", statsd.update_every);
@@ -1233,14 +1235,8 @@ void *statsd_main(void *ptr) {
1235 if(config_get_boolean(CONFIG_SECTION_STATSD, "gaps on timers (deleteTimers)", 0))
1236 statsd.timers.default_options |= STATSD_METRIC_OPTION_SHOW_GAPS_WHEN_NOT_COLLECTED;
1237
1236 - statsd_listen_sockets_setup();
1237 - if(!statsd.sockets.opened) {
1238 - error("STATSD: No statsd sockets to listen to. statsd will be disabled.");
1239 - pthread_exit(NULL);
1240 - }
1241 -
1238 #ifdef STATSD_MULTITHREADED
1243 - statsd.threads = (int)config_get_number(CONFIG_SECTION_STATSD, "collector threads", processors);
1239 + statsd.threads = (int)config_get_number(CONFIG_SECTION_STATSD, "threads", processors);
1240 if(statsd.threads < 1) {
1241 error("STATSD: Invalid number of threads %d, using %d", statsd.threads, processors);
1242 statsd.threads = processors;
@@ -1250,6 +1246,17 @@ void *statsd_main(void *ptr) {
1246 statsd.threads = 1;
1247 #endif
1248
1249 + // ----------------------------------------------------------------------------------------------------------------
1250 + // statsd setup
1251 +
1252 + if(!statsd.enabled) return NULL;
1253 +
1254 + statsd_listen_sockets_setup();
1255 + if(!statsd.sockets.opened) {
1256 + error("STATSD: No statsd sockets to listen to. statsd will be disabled.");
1257 + pthread_exit(NULL);
1258 + }
1259 +
1260 pthread_t threads[statsd.threads];
1261 int i;
1262
@@ -1261,6 +1268,9 @@ void *statsd_main(void *ptr) {
1268 error("STATSD: cannot request detach of child thread.");
1269 }
1270
1271 + // ----------------------------------------------------------------------------------------------------------------
1272 + // statsd monitoring charts
1273 +
1274 RRDSET *st_metrics = rrdset_create_localhost(
1275 "netdata"
1276 , "statsd_metrics"
@@ -1360,6 +1370,10 @@ void *statsd_main(void *ptr) {
1370 );
1371 RRDDIM *rd_pcharts = rrddim_add(st_pcharts, "charts", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
1372
1373 +
1374 + // ----------------------------------------------------------------------------------------------------------------
1375 + // statsd thread to turn metrics into charts
1376 +
1377 usec_t step = statsd.update_every * USEC_PER_SEC;
1378 heartbeat_t hb;
1379 heartbeat_init(&hb);