added localhost as a fixed name localhost can be referred
Costa Tsaousis (ktsaou) committed
Feb 19, 2017 at 18:42 UTC
df8229daf77fd1a6d76974d62a2023d85c46419c
3 files changed
+34
-17
src/adaptive_resortable_list.c
+2
@@ -65,6 +65,7 @@ void arl_begin(ARL_BASE *base) {
65
info("ARL '%s' has %zu fast searches and %zu slow searches. Is the source really changing so fast?"
66
, base->name, base->fast, base->slow);
67
68
+ /*
69
if(unlikely(base->iteration % 60 == 0)) {
70
info("ARL '%s' statistics: iteration %zu, expected %zu, wanted %zu, allocated %zu, fred %zu, relinkings %zu, found %zu, added %zu, fast %zu, slow %zu"
71
, base->name
@@ -82,6 +83,7 @@ void arl_begin(ARL_BASE *base) {
83
// for(e = base->head; e; e = e->next) fprintf(stderr, "%s ", e->name);
84
// fprintf(stderr, "\n");
85
}
86
+ */
87
}
88
#endif
89
src/rrdset.c
+17
-17
@@ -503,29 +503,29 @@ void rrdset_next_usec(RRDSET *st, usec_t microseconds)
503
}
504
else {
505
// microseconds has the time since the last collection
506
-#ifdef NETDATA_INTERNAL_CHECKS
507
- usec_t now_usec = timeval_usec(&now);
508
- usec_t last_usec = timeval_usec(&st->last_collected_time);
509
-#endif
506
+//#ifdef NETDATA_INTERNAL_CHECKS
507
+// usec_t now_usec = timeval_usec(&now);
508
+// usec_t last_usec = timeval_usec(&st->last_collected_time);
509
+//#endif
510
usec_t since_last_usec = dt_usec(&now, &st->last_collected_time);
511
512
// verify the microseconds given is good
513
if(unlikely(microseconds > since_last_usec)) {
514
debug(D_RRD_CALLS, "dt %llu usec given is too big - it leads %llu usec to the future, for chart '%s' (%s).", microseconds, microseconds - since_last_usec, st->name, st->id);
515
516
-#ifdef NETDATA_INTERNAL_CHECKS
517
- if(unlikely(last_usec + microseconds > now_usec + 1000))
518
- error("dt %llu usec given is too big - it leads %llu usec to the future, for chart '%s' (%s).", microseconds, microseconds - since_last_usec, st->name, st->id);
519
-#endif
516
+//#ifdef NETDATA_INTERNAL_CHECKS
517
+// if(unlikely(last_usec + microseconds > now_usec + 1000))
518
+// error("dt %llu usec given is too big - it leads %llu usec to the future, for chart '%s' (%s).", microseconds, microseconds - since_last_usec, st->name, st->id);
519
+//#endif
520
521
microseconds = since_last_usec;
522
}
523
else if(unlikely(microseconds < since_last_usec * 0.8)) {
524
debug(D_RRD_CALLS, "dt %llu usec given is too small - expected %llu usec up to -20%%, for chart '%s' (%s).", microseconds, since_last_usec, st->name, st->id);
525
526
-#ifdef NETDATA_INTERNAL_CHECKS
527
- error("dt %llu usec given is too small - expected %llu usec up to -20%%, for chart '%s' (%s).", microseconds, since_last_usec, st->name, st->id);
528
-#endif
526
+//#ifdef NETDATA_INTERNAL_CHECKS
527
+// error("dt %llu usec given is too small - expected %llu usec up to -20%%, for chart '%s' (%s).", microseconds, since_last_usec, st->name, st->id);
528
+//#endif
529
microseconds = since_last_usec;
530
}
531
}
@@ -866,9 +866,9 @@ usec_t rrdset_done(RRDSET *st) {
866
if(unlikely(rrdset_flag_check(st, RRDSET_FLAG_DEBUG)))
867
debug(D_RRD_STATS, "%s: THIS IS IN THE SAME INTERPOLATION POINT", st->name);
868
869
-#ifdef NETDATA_INTERNAL_CHECKS
870
- info("%s is collected in the same interpolation point: short by %llu microseconds", st->name, next_store_ut - now_collect_ut);
871
-#endif
869
+//#ifdef NETDATA_INTERNAL_CHECKS
870
+// info("%s is collected in the same interpolation point: short by %llu microseconds", st->name, next_store_ut - now_collect_ut);
871
+//#endif
872
}
873
874
usec_t first_ut = last_stored_ut;
@@ -876,9 +876,9 @@ usec_t rrdset_done(RRDSET *st) {
876
if((now_collect_ut % (update_every_ut)) == 0) iterations++;
877
878
for( ; next_store_ut <= now_collect_ut ; last_collect_ut = next_store_ut, next_store_ut += update_every_ut, iterations-- ) {
879
-#ifdef NETDATA_INTERNAL_CHECKS
880
- if(iterations < 0) { error("%s: iterations calculation wrapped! first_ut = %llu, last_stored_ut = %llu, next_store_ut = %llu, now_collect_ut = %llu", st->name, first_ut, last_stored_ut, next_store_ut, now_collect_ut); }
881
-#endif
879
+//#ifdef NETDATA_INTERNAL_CHECKS
880
+// if(iterations < 0) { error("%s: iterations calculation wrapped! first_ut = %llu, last_stored_ut = %llu, next_store_ut = %llu, now_collect_ut = %llu", st->name, first_ut, last_stored_ut, next_store_ut, now_collect_ut); }
881
+//#endif
882
883
if(unlikely(rrdset_flag_check(st, RRDSET_FLAG_DEBUG))) {
884
debug(D_RRD_STATS, "%s: last_stored_ut = %0.3Lf (last updated time)", st->name, (long double)last_stored_ut/1000000.0);
src/web_client.c
+15
@@ -2078,6 +2078,12 @@ static inline void web_client_send_http_header(struct web_client *w) {
2078
static inline int web_client_process_url(RRDHOST *host, struct web_client *w, char *url);
2079
2080
static inline int web_client_switch_host(RRDHOST *host, struct web_client *w, char *url) {
2081
+ static uint32_t hash_localhost = 0;
2082
+
2083
+ if(unlikely(!hash_localhost)) {
2084
+ hash_localhost = simple_hash("localhost");
2085
+ }
2086
+
2087
if(host != localhost) {
2088
buffer_flush(w->response.data);
2089
buffer_strcat(w->response.data, "Nesting of hosts is not allowed.");
@@ -2088,7 +2094,16 @@ static inline int web_client_switch_host(RRDHOST *host, struct web_client *w, ch
2094
if(tok && *tok) {
2095
debug(D_WEB_CLIENT, "%llu: Searching for host with name '%s'.", w->id, tok);
2096
2097
+ // copy the URL, we need it to serve files
2098
+ w->last_url[0] = '/';
2099
+ if(url && *url) strncpyz(&w->last_url[1], url, URL_MAX - 1);
2100
+ else w->last_url[1] = '\0';
2101
+
2102
uint32_t hash = simple_hash(tok);
2103
+
2104
+ if(unlikely(hash == hash_localhost && !strcmp(tok, "localhost")))
2105
+ return web_client_process_url(localhost, w, url);
2106
+
2107
RRDHOST *h;
2108
for(h = localhost; h; h = h->next) {
2109
if(unlikely((hash == h->hash_hostname && !strcmp(tok, h->hostname)) ||