]> arthur.barton.de Git - netdata.git/commitdiff
each host can have its own settings for history, update_every, rrd memory mode, healt...
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 18 Feb 2017 16:28:31 +0000 (18:28 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Tue, 21 Feb 2017 23:00:23 +0000 (01:00 +0200)
22 files changed:
src/freebsd_sysctl.c
src/global_statistics.c
src/ipc.c
src/main.c
src/plugin_checks.c
src/plugin_freebsd.c
src/plugin_idlejitter.c
src/plugin_macos.c
src/plugin_nfacct.c
src/plugin_proc.c
src/plugin_proc_diskspace.c
src/plugin_tc.c
src/plugins_d.c
src/registry.c
src/rrd.c
src/rrd.h
src/rrd2json.c
src/rrdhost.c
src/rrdset.c
src/sys_fs_cgroup.c
src/unit_test.c
src/web_client.c

index 026ad4d39b95c6233faa7f0c1ecd99ba6e24b04b..c01e8973899ff0a01e0435bb768565af3fb99c6b 100644 (file)
@@ -936,7 +936,7 @@ int do_freebsd_sysctl(int update_every, usec_t dt) {
 
                 st = rrdset_find_localhost("system.ipc_semaphores");
                 if (unlikely(!st)) {
-                    st = rrdset_create_localhost("system", "ipc_semaphores", NULL, "ipc semaphores", NULL, "IPC Semaphores", "semaphores", 1000, rrd_update_every, RRDSET_TYPE_AREA);
+                    st = rrdset_create_localhost("system", "ipc_semaphores", NULL, "ipc semaphores", NULL, "IPC Semaphores", "semaphores", 1000, localhost->rrd_update_every, RRDSET_TYPE_AREA);
                     rrddim_add(st, "semaphores", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
                 }
                 else rrdset_next(st);
@@ -948,7 +948,7 @@ int do_freebsd_sysctl(int update_every, usec_t dt) {
 
                 st = rrdset_find_localhost("system.ipc_semaphore_arrays");
                 if (unlikely(!st)) {
-                    st = rrdset_create_localhost("system", "ipc_semaphore_arrays", NULL, "ipc semaphores", NULL, "IPC Semaphore Arrays", "arrays", 1000, rrd_update_every, RRDSET_TYPE_AREA);
+                    st = rrdset_create_localhost("system", "ipc_semaphore_arrays", NULL, "ipc semaphores", NULL, "IPC Semaphore Arrays", "arrays", 1000, localhost->rrd_update_every, RRDSET_TYPE_AREA);
                     rrddim_add(st, "arrays", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
                 }
                 else rrdset_next(st);
@@ -984,7 +984,7 @@ int do_freebsd_sysctl(int update_every, usec_t dt) {
 
                 st = rrdset_find_localhost("system.ipc_shared_mem_segs");
                 if (unlikely(!st)) {
-                    st = rrdset_create_localhost("system", "ipc_shared_mem_segs", NULL, "ipc shared memory", NULL, "IPC Shared Memory Segments", "segments", 1000, rrd_update_every, RRDSET_TYPE_AREA);
+                    st = rrdset_create_localhost("system", "ipc_shared_mem_segs", NULL, "ipc shared memory", NULL, "IPC Shared Memory Segments", "segments", 1000, localhost->rrd_update_every, RRDSET_TYPE_AREA);
                     rrddim_add(st, "segments", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
                 }
                 else rrdset_next(st);
@@ -996,7 +996,7 @@ int do_freebsd_sysctl(int update_every, usec_t dt) {
 
                 st = rrdset_find_localhost("system.ipc_shared_mem_size");
                 if (unlikely(!st)) {
-                    st = rrdset_create_localhost("system", "ipc_shared_mem_size", NULL, "ipc shared memory", NULL, "IPC Shared Memory Segments Size", "kilobytes", 1000, rrd_update_every, RRDSET_TYPE_AREA);
+                    st = rrdset_create_localhost("system", "ipc_shared_mem_size", NULL, "ipc shared memory", NULL, "IPC Shared Memory Segments Size", "kilobytes", 1000, localhost->rrd_update_every, RRDSET_TYPE_AREA);
                     rrddim_add(st, "allocated", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE);
                 }
                 else rrdset_next(st);
@@ -1036,7 +1036,7 @@ int do_freebsd_sysctl(int update_every, usec_t dt) {
 
                 st = rrdset_find_localhost("system.ipc_msq_queues");
                 if (unlikely(!st)) {
-                    st = rrdset_create_localhost("system", "ipc_msq_queues", NULL, "ipc message queues", NULL, "Number of IPC Message Queues", "queues", 990, rrd_update_every, RRDSET_TYPE_AREA);
+                    st = rrdset_create_localhost("system", "ipc_msq_queues", NULL, "ipc message queues", NULL, "Number of IPC Message Queues", "queues", 990, localhost->rrd_update_every, RRDSET_TYPE_AREA);
                     rrddim_add(st, "queues", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
                 }
                 else rrdset_next(st);
@@ -1048,7 +1048,7 @@ int do_freebsd_sysctl(int update_every, usec_t dt) {
 
                 st = rrdset_find_localhost("system.ipc_msq_messages");
                 if (unlikely(!st)) {
-                    st = rrdset_create_localhost("system", "ipc_msq_messages", NULL, "ipc message queues", NULL, "Number of Messages in IPC Message Queues", "messages", 1000, rrd_update_every, RRDSET_TYPE_AREA);
+                    st = rrdset_create_localhost("system", "ipc_msq_messages", NULL, "ipc message queues", NULL, "Number of Messages in IPC Message Queues", "messages", 1000, localhost->rrd_update_every, RRDSET_TYPE_AREA);
                     rrddim_add(st, "messages", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
                 }
                 else rrdset_next(st);
@@ -1060,7 +1060,7 @@ int do_freebsd_sysctl(int update_every, usec_t dt) {
 
                 st = rrdset_find_localhost("system.ipc_msq_size");
                 if (unlikely(!st)) {
-                    st = rrdset_create_localhost("system", "ipc_msq_size", NULL, "ipc message queues", NULL, "Size of IPC Message Queues", "bytes", 1100, rrd_update_every, RRDSET_TYPE_LINE);
+                    st = rrdset_create_localhost("system", "ipc_msq_size", NULL, "ipc message queues", NULL, "Size of IPC Message Queues", "bytes", 1100, localhost->rrd_update_every, RRDSET_TYPE_LINE);
                     rrddim_add(st, "allocated", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
                     rrddim_add(st, "used", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
                 }
index d9868d2268209a327449a6f0c6037808c54de555..c3d63043e13967a6efbb48fcfb4734d271c3f078 100644 (file)
@@ -133,7 +133,7 @@ void global_statistics_charts(void) {
     if (!stcpu_thread) {
         stcpu_thread = rrdset_create_localhost("netdata", "plugin_proc_cpu", NULL, "proc", NULL
                                                , "NetData Proc Plugin CPU usage", "milliseconds/s", 132000
-                                               , rrd_update_every, RRDSET_TYPE_STACKED);
+                                               , localhost->rrd_update_every, RRDSET_TYPE_STACKED);
 
         rrddim_add(stcpu_thread, "user", NULL, 1, 1000, RRD_ALGORITHM_INCREMENTAL);
         rrddim_add(stcpu_thread, "system", NULL, 1, 1000, RRD_ALGORITHM_INCREMENTAL);
@@ -148,7 +148,7 @@ void global_statistics_charts(void) {
     if (!stcpu) stcpu = rrdset_find_localhost("netdata.server_cpu");
     if (!stcpu) {
         stcpu = rrdset_create_localhost("netdata", "server_cpu", NULL, "netdata", NULL, "NetData CPU usage"
-                                        , "milliseconds/s", 130000, rrd_update_every, RRDSET_TYPE_STACKED);
+                                        , "milliseconds/s", 130000, localhost->rrd_update_every, RRDSET_TYPE_STACKED);
 
         rrddim_add(stcpu, "user", NULL, 1, 1000, RRD_ALGORITHM_INCREMENTAL);
         rrddim_add(stcpu, "system", NULL, 1, 1000, RRD_ALGORITHM_INCREMENTAL);
@@ -163,7 +163,7 @@ void global_statistics_charts(void) {
     if (!stclients) stclients = rrdset_find_localhost("netdata.clients");
     if (!stclients) {
         stclients = rrdset_create_localhost("netdata", "clients", NULL, "netdata", NULL, "NetData Web Clients"
-                                            , "connected clients", 130200, rrd_update_every, RRDSET_TYPE_LINE);
+                                            , "connected clients", 130200, localhost->rrd_update_every, RRDSET_TYPE_LINE);
 
         rrddim_add(stclients, "clients", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
     } else rrdset_next(stclients);
@@ -176,7 +176,7 @@ void global_statistics_charts(void) {
     if (!streqs) streqs = rrdset_find_localhost("netdata.requests");
     if (!streqs) {
         streqs = rrdset_create_localhost("netdata", "requests", NULL, "netdata", NULL, "NetData Web Requests"
-                                         , "requests/s", 130300, rrd_update_every, RRDSET_TYPE_LINE);
+                                         , "requests/s", 130300, localhost->rrd_update_every, RRDSET_TYPE_LINE);
 
         rrddim_add(streqs, "requests", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
     } else rrdset_next(streqs);
@@ -189,7 +189,7 @@ void global_statistics_charts(void) {
     if (!stbytes) stbytes = rrdset_find_localhost("netdata.net");
     if (!stbytes) {
         stbytes = rrdset_create_localhost("netdata", "net", NULL, "netdata", NULL, "NetData Network Traffic"
-                                          , "kilobits/s", 130000, rrd_update_every, RRDSET_TYPE_AREA);
+                                          , "kilobits/s", 130000, localhost->rrd_update_every, RRDSET_TYPE_AREA);
 
         rrddim_add(stbytes, "in", NULL, 8, 1024, RRD_ALGORITHM_INCREMENTAL);
         rrddim_add(stbytes, "out", NULL, -8, 1024, RRD_ALGORITHM_INCREMENTAL);
@@ -204,7 +204,7 @@ void global_statistics_charts(void) {
     if (!stduration) stduration = rrdset_find_localhost("netdata.response_time");
     if (!stduration) {
         stduration = rrdset_create_localhost("netdata", "response_time", NULL, "netdata", NULL
-                                             , "NetData API Response Time", "ms/request", 130400, rrd_update_every
+                                             , "NetData API Response Time", "ms/request", 130400, localhost->rrd_update_every
                                              , RRDSET_TYPE_LINE);
 
         rrddim_add(stduration, "average", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
@@ -237,7 +237,7 @@ void global_statistics_charts(void) {
     if (!stcompression) {
         stcompression = rrdset_create_localhost("netdata", "compression_ratio", NULL, "netdata", NULL
                                                 , "NetData API Responses Compression Savings Ratio", "percentage"
-                                                , 130500, rrd_update_every, RRDSET_TYPE_LINE);
+                                                , 130500, localhost->rrd_update_every, RRDSET_TYPE_LINE);
 
         rrddim_add(stcompression, "savings", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
     } else rrdset_next(stcompression);
index e4403e04304860468855aa99a83a0c53809c762f..1dabf5e192652ae5796acf71dd001c9027ecad54 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -194,7 +194,7 @@ int do_ipc(int update_every, usec_t dt) {
         semaphores = rrdset_find_localhost("system.ipc_semaphores");
         if(!semaphores) {
             semaphores = rrdset_create_localhost("system", "ipc_semaphores", NULL, "ipc semaphores", NULL
-                                                 , "IPC Semaphores", "semaphores", 1000, rrd_update_every
+                                                 , "IPC Semaphores", "semaphores", 1000, localhost->rrd_update_every
                                                  , RRDSET_TYPE_AREA);
             rrddim_add(semaphores, "semaphores", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
         }
@@ -202,7 +202,7 @@ int do_ipc(int update_every, usec_t dt) {
         arrays = rrdset_find_localhost("system.ipc_semaphore_arrays");
         if(!arrays) {
             arrays = rrdset_create_localhost("system", "ipc_semaphore_arrays", NULL, "ipc semaphores", NULL
-                                             , "IPC Semaphore Arrays", "arrays", 1000, rrd_update_every
+                                             , "IPC Semaphore Arrays", "arrays", 1000, localhost->rrd_update_every
                                              , RRDSET_TYPE_AREA);
             rrddim_add(arrays, "arrays", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
         }
index 1100b393e6b835662934ed18d77f153c2026393f..d56af23e75edf83c2f0abce29320d44ad558016d 100644 (file)
@@ -443,7 +443,7 @@ int main(int argc, char **argv) {
                         char* stacksize_string = "stacksize=";
                         char* debug_flags_string = "debug_flags=";
                         if(strcmp(optarg, "unittest") == 0) {
-                            rrd_update_every = 1;
+                            default_localhost_rrd_update_every = 1;
                             if(run_all_mockup_tests()) exit(1);
                             if(unit_test_storage()) exit(1);
                             fprintf(stderr, "\n\nALL TESTS PASSED\n\n");
@@ -654,28 +654,28 @@ int main(int argc, char **argv) {
 
         // --------------------------------------------------------------------
 
-        rrd_default_history_entries = (int) config_get_number("global", "history", RRD_DEFAULT_HISTORY_ENTRIES);
-        if(rrd_default_history_entries < 5 || rrd_default_history_entries > RRD_HISTORY_ENTRIES_MAX) {
-            error("Invalid history entries %d given. Defaulting to %d.", rrd_default_history_entries, RRD_DEFAULT_HISTORY_ENTRIES);
-            rrd_default_history_entries = RRD_DEFAULT_HISTORY_ENTRIES;
+        default_localhost_rrd_history_entries = (int) config_get_number("global", "history", RRD_DEFAULT_HISTORY_ENTRIES);
+        if(default_localhost_rrd_history_entries < 5 || default_localhost_rrd_history_entries > RRD_HISTORY_ENTRIES_MAX) {
+            error("Invalid history entries %d given. Defaulting to %d.", default_localhost_rrd_history_entries, RRD_DEFAULT_HISTORY_ENTRIES);
+            default_localhost_rrd_history_entries = RRD_DEFAULT_HISTORY_ENTRIES;
         }
         else {
-            debug(D_OPTIONS, "save lines set to %d.", rrd_default_history_entries);
+            debug(D_OPTIONS, "save lines set to %d.", default_localhost_rrd_history_entries);
         }
 
         // --------------------------------------------------------------------
 
-        rrd_update_every = (int) config_get_number("global", "update every", UPDATE_EVERY);
-        if(rrd_update_every < 1 || rrd_update_every > 600) {
-            error("Invalid data collection frequency (update every) %d given. Defaulting to %d.", rrd_update_every, UPDATE_EVERY_MAX);
-            rrd_update_every = UPDATE_EVERY;
+        default_localhost_rrd_update_every = (int) config_get_number("global", "update every", UPDATE_EVERY);
+        if(default_localhost_rrd_update_every < 1 || default_localhost_rrd_update_every > 600) {
+            error("Invalid data collection frequency (update every) %d given. Defaulting to %d.", default_localhost_rrd_update_every, UPDATE_EVERY_MAX);
+            default_localhost_rrd_update_every = UPDATE_EVERY;
         }
-        else debug(D_OPTIONS, "update timer set to %d.", rrd_update_every);
+        else debug(D_OPTIONS, "update timer set to %d.", default_localhost_rrd_update_every);
 
         // let the plugins know the min update_every
         {
             char buf[16];
-            snprintfz(buf, 15, "%d", rrd_update_every);
+            snprintfz(buf, 15, "%d", default_localhost_rrd_update_every);
             setenv("NETDATA_UPDATE_EVERY", buf, 1);
         }
 
index 52575a66cb9eeb23b9990dc3e5229bd55704df31..3a0a83bda278f9b0f9b6c07d7c9d140a510ea673 100644 (file)
@@ -11,23 +11,23 @@ void *checks_main(void *ptr) {
     if(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) != 0)
         error("Cannot set pthread cancel state to ENABLE.");
 
-    usec_t usec = 0, susec = rrd_update_every * USEC_PER_SEC, loop_usec = 0, total_susec = 0;
+    usec_t usec = 0, susec = localhost->rrd_update_every * USEC_PER_SEC, loop_usec = 0, total_susec = 0;
     struct timeval now, last, loop;
 
     RRDSET *check1, *check2, *check3, *apps_cpu = NULL;
 
     check1 = rrdset_create_localhost("netdata", "check1", NULL, "netdata", NULL, "Caller gives microseconds"
-                                     , "a million !", 99999, rrd_update_every, RRDSET_TYPE_LINE);
+                                     , "a million !", 99999, localhost->rrd_update_every, RRDSET_TYPE_LINE);
     rrddim_add(check1, "absolute", NULL, -1, 1, RRD_ALGORITHM_ABSOLUTE);
     rrddim_add(check1, "incremental", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
 
     check2 = rrdset_create_localhost("netdata", "check2", NULL, "netdata", NULL, "Netdata calcs microseconds"
-                                     , "a million !", 99999, rrd_update_every, RRDSET_TYPE_LINE);
+                                     , "a million !", 99999, localhost->rrd_update_every, RRDSET_TYPE_LINE);
     rrddim_add(check2, "absolute", NULL, -1, 1, RRD_ALGORITHM_ABSOLUTE);
     rrddim_add(check2, "incremental", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
 
     check3 = rrdset_create_localhost("netdata", "checkdt", NULL, "netdata", NULL, "Clock difference"
-                                     , "microseconds diff", 99999, rrd_update_every, RRDSET_TYPE_LINE);
+                                     , "microseconds diff", 99999, localhost->rrd_update_every, RRDSET_TYPE_LINE);
     rrddim_add(check3, "caller", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
     rrddim_add(check3, "netdata", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
     rrddim_add(check3, "apps.plugin", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
@@ -42,8 +42,8 @@ void *checks_main(void *ptr) {
         usec = loop_usec - susec;
         debug(D_PROCNETDEV_LOOP, "CHECK: last loop took %llu usec (worked for %llu, sleeped for %llu).", loop_usec, usec, susec);
 
-        if(usec < (rrd_update_every * USEC_PER_SEC / 2ULL)) susec = (rrd_update_every * USEC_PER_SEC) - usec;
-        else susec = rrd_update_every * USEC_PER_SEC / 2ULL;
+        if(usec < (localhost->rrd_update_every * USEC_PER_SEC / 2ULL)) susec = (localhost->rrd_update_every * USEC_PER_SEC) - usec;
+        else susec = localhost->rrd_update_every * USEC_PER_SEC / 2ULL;
 
         // --------------------------------------------------------------------
         // Calculate loop time
index 4fef148ab6a86da1e82e81f62600b51e850623a5..3490e70edef2f587d758ce0bb1adf61ecb6a77db 100644 (file)
@@ -18,7 +18,7 @@ void *freebsd_main(void *ptr) {
     // keep track of the time each module was called
     unsigned long long sutime_freebsd_sysctl = 0ULL;
 
-    usec_t step = rrd_update_every * USEC_PER_SEC;
+    usec_t step = localhost->rrd_update_every * USEC_PER_SEC;
     heartbeat_t hb;
     heartbeat_init(&hb);
     for(;;) {
@@ -30,7 +30,7 @@ void *freebsd_main(void *ptr) {
 
         if(!vdo_freebsd_sysctl) {
             debug(D_PROCNETDEV_LOOP, "FREEBSD: calling do_freebsd_sysctl().");
-            vdo_freebsd_sysctl = do_freebsd_sysctl(rrd_update_every, hb_dt);
+            vdo_freebsd_sysctl = do_freebsd_sysctl(localhost->rrd_update_every, hb_dt);
         }
         if(unlikely(netdata_exit)) break;
 
index bff85d1343d52b6e05b33290c1e3bd0c7360acd7..66b3b60415ca5beccba40f2c515a0d51d77c8976 100644 (file)
@@ -22,7 +22,7 @@ void *cpuidlejitter_main(void *ptr) {
     RRDSET *st = rrdset_find_localhost("system.idlejitter");
     if(!st) {
         st = rrdset_create_localhost("system", "idlejitter", NULL, "processes", NULL, "CPU Idle Jitter"
-                                     , "microseconds lost/s", 9999, rrd_update_every, RRDSET_TYPE_LINE);
+                                     , "microseconds lost/s", 9999, localhost->rrd_update_every, RRDSET_TYPE_LINE);
         rrddim_add(st, "jitter", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
     }
 
@@ -31,7 +31,7 @@ void *cpuidlejitter_main(void *ptr) {
     for(counter = 0; 1 ;counter++) {
         usec_t usec = 0, susec = 0;
 
-        while(susec < (rrd_update_every * USEC_PER_SEC)) {
+        while(susec < (localhost->rrd_update_every * USEC_PER_SEC)) {
 
             now_monotonic_timeval(&before);
             sleep_usec(sleep_ms * 1000);
index 54965c5d4ec92813750f0d00265b54e1458268b6..4e84a084d69f3136a068756f6bacf6a98e7e2a9f 100644 (file)
@@ -22,7 +22,7 @@ void *macos_main(void *ptr) {
     unsigned long long sutime_macos_mach_smi = 0ULL;
     unsigned long long sutime_macos_iokit = 0ULL;
 
-    usec_t step = rrd_update_every * USEC_PER_SEC;
+    usec_t step = localhost->rrd_update_every * USEC_PER_SEC;
     heartbeat_t hb;
     heartbeat_init(&hb);
     for(;;) {
@@ -34,19 +34,19 @@ void *macos_main(void *ptr) {
 
         if(!vdo_macos_sysctl) {
             debug(D_PROCNETDEV_LOOP, "MACOS: calling do_macos_sysctl().");
-            vdo_macos_sysctl = do_macos_sysctl(rrd_update_every, hb_dt);
+            vdo_macos_sysctl = do_macos_sysctl(localhost->rrd_update_every, hb_dt);
         }
         if(unlikely(netdata_exit)) break;
 
         if(!vdo_macos_mach_smi) {
             debug(D_PROCNETDEV_LOOP, "MACOS: calling do_macos_mach_smi().");
-            vdo_macos_mach_smi = do_macos_mach_smi(rrd_update_every, hb_dt);
+            vdo_macos_mach_smi = do_macos_mach_smi(localhost->rrd_update_every, hb_dt);
         }
         if(unlikely(netdata_exit)) break;
 
         if(!vdo_macos_iokit) {
             debug(D_PROCNETDEV_LOOP, "MACOS: calling do_macos_iokit().");
-            vdo_macos_iokit = do_macos_iokit(rrd_update_every, hb_dt);
+            vdo_macos_iokit = do_macos_iokit(localhost->rrd_update_every, hb_dt);
         }
         if(unlikely(netdata_exit)) break;
 
index ca67ec19262b808c0ac7a8f7a9524bdda0d56b13..5140d7bc8bcde050ca8714517a3f87684fdc8d94 100644 (file)
@@ -128,8 +128,8 @@ void *nfacct_main(void *ptr) {
         usec = dt_usec(&now, &last) - susec;
         debug(D_NFACCT_LOOP, "nfacct.plugin: last loop took %llu usec (worked for %llu, sleeped for %llu).", usec + susec, usec, susec);
 
-        if(usec < (rrd_update_every * 1000000ULL / 2ULL)) susec = (rrd_update_every * 1000000ULL) - usec;
-        else susec = rrd_update_every * 1000000ULL / 2ULL;
+        if(usec < (default_localhost_rrd_update_every * 1000000ULL / 2ULL)) susec = (default_localhost_rrd_update_every * 1000000ULL) - usec;
+        else susec = default_localhost_rrd_update_every * 1000000ULL / 2ULL;
 
 
         // --------------------------------------------------------------------
@@ -139,17 +139,17 @@ void *nfacct_main(void *ptr) {
 
             st = rrdset_find_bytype("netfilter", "nfacct_packets");
             if(!st) {
-                st = rrdset_create("netfilter", "nfacct_packets", NULL, "nfacct", NULL, "Netfilter Accounting Packets", "packets/s", 3206, rrd_update_every, RRDSET_TYPE_STACKED);
+                st = rrdset_create("netfilter", "nfacct_packets", NULL, "nfacct", NULL, "Netfilter Accounting Packets", "packets/s", 3206, default_localhost_rrd_update_every, RRDSET_TYPE_STACKED);
 
                 for(i = 0; i < nfacct_list->len ; i++)
-                    rrddim_add(st, nfacct_list->data[i].name, NULL, 1, rrd_update_every, RRD_ALGORITHM_INCREMENTAL);
+                    rrddim_add(st, nfacct_list->data[i].name, NULL, 1, default_localhost_rrd_update_every, RRD_ALGORITHM_INCREMENTAL);
             }
             else rrdset_next(st);
 
             for(i = 0; i < nfacct_list->len ; i++) {
                 RRDDIM *rd = rrddim_find(st, nfacct_list->data[i].name);
 
-                if(!rd) rd = rrddim_add(st, nfacct_list->data[i].name, NULL, 1, rrd_update_every, RRD_ALGORITHM_INCREMENTAL);
+                if(!rd) rd = rrddim_add(st, nfacct_list->data[i].name, NULL, 1, default_localhost_rrd_update_every, RRD_ALGORITHM_INCREMENTAL);
                 if(rd) rrddim_set_by_pointer(st, rd, nfacct_list->data[i].pkts);
             }
 
@@ -159,17 +159,17 @@ void *nfacct_main(void *ptr) {
 
             st = rrdset_find_bytype("netfilter", "nfacct_bytes");
             if(!st) {
-                st = rrdset_create("netfilter", "nfacct_bytes", NULL, "nfacct", NULL, "Netfilter Accounting Bandwidth", "kilobytes/s", 3207, rrd_update_every, RRDSET_TYPE_STACKED);
+                st = rrdset_create("netfilter", "nfacct_bytes", NULL, "nfacct", NULL, "Netfilter Accounting Bandwidth", "kilobytes/s", 3207, default_localhost_rrd_update_every, RRDSET_TYPE_STACKED);
 
                 for(i = 0; i < nfacct_list->len ; i++)
-                    rrddim_add(st, nfacct_list->data[i].name, NULL, 1, 1000 * rrd_update_every, RRD_ALGORITHM_INCREMENTAL);
+                    rrddim_add(st, nfacct_list->data[i].name, NULL, 1, 1000 * default_localhost_rrd_update_every, RRD_ALGORITHM_INCREMENTAL);
             }
             else rrdset_next(st);
 
             for(i = 0; i < nfacct_list->len ; i++) {
                 RRDDIM *rd = rrddim_find(st, nfacct_list->data[i].name);
 
-                if(!rd) rd = rrddim_add(st, nfacct_list->data[i].name, NULL, 1, 1000 * rrd_update_every, RRD_ALGORITHM_INCREMENTAL);
+                if(!rd) rd = rrddim_add(st, nfacct_list->data[i].name, NULL, 1, 1000 * default_localhost_rrd_update_every, RRD_ALGORITHM_INCREMENTAL);
                 if(rd) rrddim_set_by_pointer(st, rd, nfacct_list->data[i].bytes);
             }
 
index bc300c27432807f32cfc9bc192c6201fbb529ffc..2ca77491de4633736f6ea43e1b17f091b3bdf3d9 100644 (file)
@@ -79,7 +79,7 @@ void *proc_main(void *ptr) {
         pm->rd = NULL;
     }
 
-    usec_t step = rrd_update_every * USEC_PER_SEC;
+    usec_t step = localhost->rrd_update_every * USEC_PER_SEC;
     heartbeat_t hb;
     heartbeat_init(&hb);
 
@@ -97,7 +97,7 @@ void *proc_main(void *ptr) {
 
             debug(D_PROCNETDEV_LOOP, "PROC calling %s.", pm->name);
 
-            pm->enabled = !pm->func(rrd_update_every, hb_dt);
+            pm->enabled = !pm->func(localhost->rrd_update_every, hb_dt);
             pm->duration = heartbeat_dt_usec(&hb) - duration;
             duration += pm->duration;
 
@@ -117,7 +117,7 @@ void *proc_main(void *ptr) {
                 if(!st) {
                     st = rrdset_create_localhost("netdata", "plugin_proc_modules", NULL, "proc", NULL
                                                  , "NetData Proc Plugin Modules Durations", "milliseconds/run", 132001
-                                                 , rrd_update_every, RRDSET_TYPE_STACKED);
+                                                 , localhost->rrd_update_every, RRDSET_TYPE_STACKED);
 
                     for(i = 0 ; proc_modules[i].name ;i++) {
                         struct proc_module *pm = &proc_modules[i];
index 984c0ceb6905b7b84f37f6fd95d5e156c45e583f..9e11f85c6331a2320612f7ed87341691fb79b881 100644 (file)
@@ -223,9 +223,9 @@ void *proc_diskspace_main(void *ptr) {
 
     int vdo_cpu_netdata = config_get_boolean("plugin:proc", "netdata server resources", 1);
 
-    int update_every = (int)config_get_number("plugin:proc:diskspace", "update every", rrd_update_every);
-    if(update_every < rrd_update_every)
-        update_every = rrd_update_every;
+    int update_every = (int)config_get_number("plugin:proc:diskspace", "update every", localhost->rrd_update_every);
+    if(update_every < localhost->rrd_update_every)
+        update_every = localhost->rrd_update_every;
 
     check_for_new_mountpoints_every = (int)config_get_number("plugin:proc:diskspace", "check for new mount points every", check_for_new_mountpoints_every);
     if(check_for_new_mountpoints_every < update_every)
index a300ea6acb8aa17dec5842153b445affba900352..0cd85ee8c0bd184300aed6901b4ae1a731ba828d 100644 (file)
@@ -376,7 +376,7 @@ static inline void tc_device_commit(struct tc_device *d) {
         if(unlikely(!d->st_bytes))
             d->st_bytes = rrdset_create_localhost(RRD_TYPE_TC, d->id, d->name ? d->name : d->id
                                                   , d->family ? d->family : d->id, RRD_TYPE_TC ".qos", "Class Usage"
-                                                  , "kilobits/s", 7000, rrd_update_every
+                                                  , "kilobits/s", 7000, localhost->rrd_update_every
                                                   , d->enabled_all_classes_qdiscs ? RRDSET_TYPE_LINE
                                                                                   : RRDSET_TYPE_STACKED);
 
@@ -415,7 +415,7 @@ static inline void tc_device_commit(struct tc_device *d) {
 
             d->st_packets = rrdset_create_localhost(RRD_TYPE_TC, id, name, d->family ? d->family : d->id
                                                     , RRD_TYPE_TC ".qos_packets", "Class Packets", "packets/s", 7010
-                                                    , rrd_update_every, d->enabled_all_classes_qdiscs ? RRDSET_TYPE_LINE
+                                                    , localhost->rrd_update_every, d->enabled_all_classes_qdiscs ? RRDSET_TYPE_LINE
                                                                                                       : RRDSET_TYPE_STACKED);
         }
         else {
@@ -458,7 +458,7 @@ static inline void tc_device_commit(struct tc_device *d) {
 
             d->st_dropped = rrdset_create_localhost(RRD_TYPE_TC, id, name, d->family ? d->family : d->id
                                                     , RRD_TYPE_TC ".qos_dropped", "Class Dropped Packets", "packets/s"
-                                                    , 7020, rrd_update_every
+                                                    , 7020, localhost->rrd_update_every
                                                     , d->enabled_all_classes_qdiscs ? RRDSET_TYPE_LINE
                                                                                     : RRDSET_TYPE_STACKED);
         }
@@ -502,7 +502,7 @@ static inline void tc_device_commit(struct tc_device *d) {
 
             d->st_tokens = rrdset_create_localhost(RRD_TYPE_TC, id, name, d->family ? d->family : d->id
                                                    , RRD_TYPE_TC ".qos_tokens", "Class Tokens", "tokens", 7030
-                                                   , rrd_update_every, RRDSET_TYPE_LINE);
+                                                   , localhost->rrd_update_every, RRDSET_TYPE_LINE);
         }
         else {
             rrdset_next(d->st_tokens);
@@ -545,7 +545,7 @@ static inline void tc_device_commit(struct tc_device *d) {
 
             d->st_ctokens = rrdset_create_localhost(RRD_TYPE_TC, id, name, d->family ? d->family : d->id
                                                     , RRD_TYPE_TC ".qos_ctokens", "Class cTokens", "ctokens", 7040
-                                                    , rrd_update_every, RRDSET_TYPE_LINE);
+                                                    , localhost->rrd_update_every, RRDSET_TYPE_LINE);
         }
         else {
             debug(D_TC_LOOP, "TC: Updating _ctokens chart for device '%s'", d->name?d->name:d->id);
@@ -807,7 +807,7 @@ void *tc_main(void *ptr) {
         struct tc_device *device = NULL;
         struct tc_class *class = NULL;
 
-        snprintfz(buffer, TC_LINE_MAX, "exec %s %d", tc_script, rrd_update_every);
+        snprintfz(buffer, TC_LINE_MAX, "exec %s %d", tc_script, localhost->rrd_update_every);
         debug(D_TC_LOOP, "executing '%s'", buffer);
 
         fp = mypopen(buffer, (pid_t *)&tc_child_pid);
@@ -992,7 +992,7 @@ void *tc_main(void *ptr) {
                 if(unlikely(!stcpu)) stcpu = rrdset_find_localhost("netdata.plugin_tc_cpu");
                 if(unlikely(!stcpu)) {
                     stcpu = rrdset_create_localhost("netdata", "plugin_tc_cpu", NULL, "tc.helper", NULL
-                                                    , "NetData TC CPU usage", "milliseconds/s", 135000, rrd_update_every
+                                                    , "NetData TC CPU usage", "milliseconds/s", 135000, localhost->rrd_update_every
                                                     , RRDSET_TYPE_STACKED);
                     rrddim_add(stcpu, "user",  NULL,  1, 1000, RRD_ALGORITHM_INCREMENTAL);
                     rrddim_add(stcpu, "system", NULL, 1, 1000, RRD_ALGORITHM_INCREMENTAL);
@@ -1007,7 +1007,7 @@ void *tc_main(void *ptr) {
                 if(unlikely(!sttime)) {
                     sttime = rrdset_create_localhost("netdata", "plugin_tc_time", NULL, "tc.helper", NULL
                                                      , "NetData TC script execution", "milliseconds/run", 135001
-                                                     , rrd_update_every, RRDSET_TYPE_AREA);
+                                                     , localhost->rrd_update_every, RRDSET_TYPE_AREA);
                     rrddim_add(sttime, "run_time",  "run time",  1, 1, RRD_ALGORITHM_ABSOLUTE);
                 }
                 else rrdset_next(sttime);
@@ -1056,7 +1056,7 @@ void *tc_main(void *ptr) {
             goto cleanup;
         }
 
-        sleep((unsigned int) rrd_update_every);
+        sleep((unsigned int) localhost->rrd_update_every);
     }
 
 cleanup:
index 69d52bb9937a4258480322a93776320374211526..1c91d8fc4f3ecafdaaa51f6e62bf72688c172d90 100644 (file)
@@ -370,8 +370,8 @@ void *pluginsd_worker_thread(void *arg) {
                     // second+ run
                     usec = dt_usec(&now, &last) - susec;
                     error("PLUGINSD: %s last loop took %llu usec (worked for %llu, sleeped for %llu).\n", cd->fullfilename, usec + susec, usec, susec);
-                    if(unlikely(usec < (rrd_update_every * USEC_PER_SEC / 2ULL))) susec = (rrd_update_every * USEC_PER_SEC) - usec;
-                    else susec = rrd_update_every * USEC_PER_SEC / 2ULL;
+                    if(unlikely(usec < (localhost->rrd_update_every * USEC_PER_SEC / 2ULL))) susec = (localhost->rrd_update_every * USEC_PER_SEC) - usec;
+                    else susec = localhost->rrd_update_every * USEC_PER_SEC / 2ULL;
                 }
 
                 error("PLUGINSD: %s sleeping for %llu. Will kill with SIGCONT pid %d to wake it up.\n", cd->fullfilename, susec, cd->pid);
@@ -526,7 +526,7 @@ void *pluginsd_main(void *ptr) {
                 snprintfz(cd->fullfilename, FILENAME_MAX, "%s/%s", netdata_configured_plugins_dir, cd->filename);
 
                 cd->enabled = enabled;
-                cd->update_every = (int) config_get_number(cd->id, "update every", rrd_update_every);
+                cd->update_every = (int) config_get_number(cd->id, "update every", localhost->rrd_update_every);
                 cd->started_t = now_realtime_sec();
 
                 char *def = "";
index 732212850d2e85709d9c334412fb57d9eec92187..164c9179af1bde727babd1f66d556823b06472df 100644 (file)
@@ -326,7 +326,7 @@ void registry_statistics(void) {
     if(!sts) sts = rrdset_find_localhost("netdata.registry_sessions");
     if(!sts) {
         sts = rrdset_create_localhost("netdata", "registry_sessions", NULL, "registry", NULL
-                                      , "NetData Registry Sessions", "session", 131000, rrd_update_every
+                                      , "NetData Registry Sessions", "session", 131000, localhost->rrd_update_every
                                       , RRDSET_TYPE_LINE);
 
         rrddim_add(sts, "sessions",  NULL,  1, 1, RRD_ALGORITHM_ABSOLUTE);
@@ -341,7 +341,7 @@ void registry_statistics(void) {
     if(!stc) stc = rrdset_find_localhost("netdata.registry_entries");
     if(!stc) {
         stc = rrdset_create_localhost("netdata", "registry_entries", NULL, "registry", NULL, "NetData Registry Entries"
-                                      , "entries", 131100, rrd_update_every, RRDSET_TYPE_LINE);
+                                      , "entries", 131100, localhost->rrd_update_every, RRDSET_TYPE_LINE);
 
         rrddim_add(stc, "persons",        NULL,  1, 1, RRD_ALGORITHM_ABSOLUTE);
         rrddim_add(stc, "machines",       NULL,  1, 1, RRD_ALGORITHM_ABSOLUTE);
@@ -363,7 +363,7 @@ void registry_statistics(void) {
     if(!stm) stm = rrdset_find_localhost("netdata.registry_mem");
     if(!stm) {
         stm = rrdset_create_localhost("netdata", "registry_mem", NULL, "registry", NULL, "NetData Registry Memory", "KB"
-                                      , 131300, rrd_update_every, RRDSET_TYPE_STACKED);
+                                      , 131300, localhost->rrd_update_every, RRDSET_TYPE_STACKED);
 
         rrddim_add(stm, "persons",        NULL,  1, 1024, RRD_ALGORITHM_ABSOLUTE);
         rrddim_add(stm, "machines",       NULL,  1, 1024, RRD_ALGORITHM_ABSOLUTE);
index 2fa50d375aea324230602e26084231c7185799da..5cc72faee69928acb505ee81791653beb9f7830f 100644 (file)
--- a/src/rrd.c
+++ b/src/rrd.c
@@ -11,8 +11,8 @@
 int rrd_delete_unupdated_dimensions = 0;
 */
 
-int rrd_update_every = UPDATE_EVERY;
-int rrd_default_history_entries = RRD_DEFAULT_HISTORY_ENTRIES;
+int default_localhost_rrd_update_every = UPDATE_EVERY;
+int default_localhost_rrd_history_entries = RRD_DEFAULT_HISTORY_ENTRIES;
 RRD_MEMORY_MODE default_localhost_rrd_memory_mode = RRD_MEMORY_MODE_SAVE;
 
 
index 5ef86838a992c286e80142ae7e0985b837ab037c..cbf2260b5c2149c05ad17c1c103ca32eb9b6737d 100644 (file)
--- a/src/rrd.h
+++ b/src/rrd.h
@@ -3,11 +3,12 @@
 
 #define UPDATE_EVERY 1
 #define UPDATE_EVERY_MAX 3600
-extern int rrd_update_every;
 
 #define RRD_DEFAULT_HISTORY_ENTRIES 3600
 #define RRD_HISTORY_ENTRIES_MAX (86400*10)
-extern int rrd_default_history_entries;
+
+extern int default_localhost_rrd_update_every;
+extern int default_localhost_rrd_history_entries;
 
 #define RRD_ID_LENGTH_MAX 200
 
@@ -302,6 +303,9 @@ struct rrdhost {
     char machine_guid[GUID_LEN + 1];                // the unique ID of this host
     uint32_t hash_machine_guid;                     // the hash of the unique ID
 
+    int rrd_update_every;                           // the update frequency of the host
+    int rrd_history_entries;                        // the number of history entries for the host's charts
+
     int health_enabled;                             // 1 when this host has health enabled
     RRD_MEMORY_MODE rrd_memory_mode;                // the memory more for the charts of this host
 
index b06fb4ae66118b780ec5eba0e76e9e6ae6b37409..40e5bea78e35bc02a3f8965865031af1f9ab53c9 100644 (file)
@@ -93,8 +93,8 @@ void rrd_stats_api_v1_charts(BUFFER *wb)
         , localhost->hostname
         , program_version
         , os_type
-        , rrd_update_every
-        , rrd_default_history_entries
+        , localhost->rrd_update_every
+        , localhost->rrd_history_entries
         );
 
     pthread_rwlock_rdlock(&localhost->rrdset_root_rwlock);
@@ -438,8 +438,8 @@ void rrd_stats_all_json(BUFFER *wb)
         "\t\"memory\": %lu\n"
         "}\n"
         , localhost->hostname
-        , rrd_update_every
-        , rrd_default_history_entries
+        , localhost->rrd_update_every
+        , localhost->rrd_history_entries
         , memory
         );
 }
index 2261ac975843fd9352f0a845dd5eaba0d4661be6..e899f69dfe750179f23fc0593ad50bf159b9acf2 100644 (file)
@@ -54,8 +54,10 @@ RRDHOST *rrdhost_create(const char *hostname, const char *guid) {
 
     RRDHOST *host = callocz(1, sizeof(RRDHOST));
 
-    host->rrd_memory_mode = default_localhost_rrd_memory_mode;
-    host->health_enabled  = default_localhost_health_enabled;
+    host->rrd_update_every    = default_localhost_rrd_update_every;
+    host->rrd_history_entries = default_localhost_rrd_history_entries;
+    host->rrd_memory_mode     = default_localhost_rrd_memory_mode;
+    host->health_enabled      = default_localhost_health_enabled;
 
     pthread_rwlock_init(&(host->rrdset_root_rwlock), NULL);
 
index 0b238d114a1ea1b4d85ba7ecfb88cbf517586be6..95108813d3c32682aa0ded85145276386c26d87d 100644 (file)
@@ -234,7 +234,7 @@ RRDSET *rrdset_create(RRDHOST *host, const char *type, const char *id, const cha
         return st;
     }
 
-    long rentries = config_get_number(fullid, "history", rrd_default_history_entries);
+    long rentries = config_get_number(fullid, "history", host->rrd_history_entries);
     long entries = align_entries_to_pagesize(rentries);
     if(entries != rentries) entries = config_set_number(fullid, "history", entries);
 
index 51c2e2b75e61c3a67032cb931438fc5ff5a1dca5..50a8e622bbe194aa8be39165c587443fef4652bd 100644 (file)
@@ -64,9 +64,9 @@ void read_cgroup_plugin_configuration() {
     user_hash = simple_hash("user");
     system_hash = simple_hash("system");
 
-    cgroup_update_every = (int)config_get_number("plugin:cgroups", "update every", rrd_update_every);
-    if(cgroup_update_every < rrd_update_every)
-        cgroup_update_every = rrd_update_every;
+    cgroup_update_every = (int)config_get_number("plugin:cgroups", "update every", localhost->rrd_update_every);
+    if(cgroup_update_every < localhost->rrd_update_every)
+        cgroup_update_every = localhost->rrd_update_every;
 
     cgroup_check_for_new_every = (int)config_get_number("plugin:cgroups", "check for new cgroups every", cgroup_check_for_new_every * cgroup_update_every);
     if(cgroup_check_for_new_every < cgroup_update_every)
index b7ba4affefac616b9f32ec70770927e77fd395dc..dc6606678dde98b9688af32cafc93bae9230d905 100644 (file)
@@ -885,7 +885,7 @@ int run_test(struct test *test)
     fprintf(stderr, "\nRunning test '%s':\n%s\n", test->name, test->description);
 
     default_localhost_rrd_memory_mode = RRD_MEMORY_MODE_RAM;
-    rrd_update_every = test->update_every;
+    default_localhost_rrd_update_every = test->update_every;
 
     char name[101];
     snprintfz(name, 100, "unittest-%s", test->name);
@@ -1092,7 +1092,7 @@ int unit_test(long delay, long shift)
 
     //debug_flags = 0xffffffff;
     default_localhost_rrd_memory_mode = RRD_MEMORY_MODE_RAM;
-    rrd_update_every = 1;
+    default_localhost_rrd_update_every = 1;
 
     int do_abs = 1;
     int do_inc = 1;
index e38d70b9e2a727d9397b29fa73313ae63eb4886d..794dcc72375047a0ab5d06792ee9e00ebae2af11 100644 (file)
@@ -1532,7 +1532,7 @@ int web_client_api_old_data_request(struct web_client *w, char *url, int datasou
     debug(D_WEB_CLIENT, "%llu: Found RRD data with name '%s'.", w->id, tok);
 
     // how many entries does the client want?
-    int lines = rrd_default_history_entries;
+    int lines = (int)st->entries;
     int group_count = 1;
     time_t after = 0, before = 0;
     int group_method = GROUP_AVERAGE;
@@ -1934,7 +1934,7 @@ static inline void web_client_send_http_header(struct web_client *w) {
     // set a proper expiration date, if not already set
     if(unlikely(!w->response.data->expires)) {
         if(w->response.data->options & WB_CONTENT_NO_CACHEABLE)
-            w->response.data->expires = w->tv_ready.tv_sec + rrd_update_every;
+            w->response.data->expires = w->tv_ready.tv_sec + localhost->rrd_update_every;
         else
             w->response.data->expires = w->tv_ready.tv_sec + 86400;
     }