]> arthur.barton.de Git - netdata.git/commitdiff
added localhost as a fixed name localhost can be referred
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sun, 19 Feb 2017 16:42:05 +0000 (18:42 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Tue, 21 Feb 2017 23:00:25 +0000 (01:00 +0200)
src/adaptive_resortable_list.c
src/rrdset.c
src/web_client.c

index ac525dc6c14b3fadb418a7a3e9ab442c50821625..7ae8ba1459f2c0eef7d64c0e7cd2aa14674c1cf0 100644 (file)
@@ -65,6 +65,7 @@ void arl_begin(ARL_BASE *base) {
             info("ARL '%s' has %zu fast searches and %zu slow searches. Is the source really changing so fast?"
                  , base->name, base->fast, base->slow);
 
+        /*
         if(unlikely(base->iteration % 60 == 0)) {
             info("ARL '%s' statistics: iteration %zu, expected %zu, wanted %zu, allocated %zu, fred %zu, relinkings %zu, found %zu, added %zu, fast %zu, slow %zu"
                  , base->name
@@ -82,6 +83,7 @@ void arl_begin(ARL_BASE *base) {
             // for(e = base->head; e; e = e->next) fprintf(stderr, "%s ", e->name);
             // fprintf(stderr, "\n");
         }
+        */
     }
 #endif
 
index ef1713c258a35829a61c1e7481f7a5d0eae40663..97ecf45939251cbe40664d43144a75d14ac33e45 100644 (file)
@@ -503,29 +503,29 @@ void rrdset_next_usec(RRDSET *st, usec_t microseconds)
     }
     else {
         // microseconds has the time since the last collection
-#ifdef NETDATA_INTERNAL_CHECKS
-        usec_t now_usec = timeval_usec(&now);
-        usec_t last_usec = timeval_usec(&st->last_collected_time);
-#endif
+//#ifdef NETDATA_INTERNAL_CHECKS
+//        usec_t now_usec = timeval_usec(&now);
+//        usec_t last_usec = timeval_usec(&st->last_collected_time);
+//#endif
         usec_t since_last_usec = dt_usec(&now, &st->last_collected_time);
 
         // verify the microseconds given is good
         if(unlikely(microseconds > since_last_usec)) {
             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);
 
-#ifdef NETDATA_INTERNAL_CHECKS
-            if(unlikely(last_usec + microseconds > now_usec + 1000))
-                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);
-#endif
+//#ifdef NETDATA_INTERNAL_CHECKS
+//            if(unlikely(last_usec + microseconds > now_usec + 1000))
+//                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);
+//#endif
 
             microseconds = since_last_usec;
         }
         else if(unlikely(microseconds < since_last_usec * 0.8)) {
             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);
 
-#ifdef NETDATA_INTERNAL_CHECKS
-            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);
-#endif
+//#ifdef NETDATA_INTERNAL_CHECKS
+//            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);
+//#endif
             microseconds = since_last_usec;
         }
     }
@@ -866,9 +866,9 @@ usec_t rrdset_done(RRDSET *st) {
         if(unlikely(rrdset_flag_check(st, RRDSET_FLAG_DEBUG)))
             debug(D_RRD_STATS, "%s: THIS IS IN THE SAME INTERPOLATION POINT", st->name);
 
-#ifdef NETDATA_INTERNAL_CHECKS
-        info("%s is collected in the same interpolation point: short by %llu microseconds", st->name, next_store_ut - now_collect_ut);
-#endif
+//#ifdef NETDATA_INTERNAL_CHECKS
+//        info("%s is collected in the same interpolation point: short by %llu microseconds", st->name, next_store_ut - now_collect_ut);
+//#endif
     }
 
     usec_t first_ut = last_stored_ut;
@@ -876,9 +876,9 @@ usec_t rrdset_done(RRDSET *st) {
     if((now_collect_ut % (update_every_ut)) == 0) iterations++;
 
     for( ; next_store_ut <= now_collect_ut ; last_collect_ut = next_store_ut, next_store_ut += update_every_ut, iterations-- ) {
-#ifdef NETDATA_INTERNAL_CHECKS
-        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); }
-#endif
+//#ifdef NETDATA_INTERNAL_CHECKS
+//        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); }
+//#endif
 
         if(unlikely(rrdset_flag_check(st, RRDSET_FLAG_DEBUG))) {
             debug(D_RRD_STATS, "%s: last_stored_ut = %0.3Lf (last updated time)", st->name, (long double)last_stored_ut/1000000.0);
index e43ae26d4949d9340ce960969112ab913d383336..1b89d69a43589f3da68c0fdbf203707bafc030e0 100644 (file)
@@ -2078,6 +2078,12 @@ static inline void web_client_send_http_header(struct web_client *w) {
 static inline int web_client_process_url(RRDHOST *host, struct web_client *w, char *url);
 
 static inline int web_client_switch_host(RRDHOST *host, struct web_client *w, char *url) {
+    static uint32_t hash_localhost = 0;
+
+    if(unlikely(!hash_localhost)) {
+        hash_localhost = simple_hash("localhost");
+    }
+
     if(host != localhost) {
         buffer_flush(w->response.data);
         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
     if(tok && *tok) {
         debug(D_WEB_CLIENT, "%llu: Searching for host with name '%s'.", w->id, tok);
 
+        // copy the URL, we need it to serve files
+        w->last_url[0] = '/';
+        if(url && *url) strncpyz(&w->last_url[1], url, URL_MAX - 1);
+        else w->last_url[1] = '\0';
+
         uint32_t hash = simple_hash(tok);
+
+        if(unlikely(hash == hash_localhost && !strcmp(tok, "localhost")))
+            return web_client_process_url(localhost, w, url);
+
         RRDHOST *h;
         for(h = localhost; h; h = h->next) {
             if(unlikely((hash == h->hash_hostname && !strcmp(tok, h->hostname)) ||