@cryptotaxi247 / netdata-1 / commits / bf06c2fb0

each host can have its own settings for history, update_every, rrd memory mode, health enabled

Costa Tsaousis (ktsaou) committed Feb 18, 2017 at 18:28 UTC bf06c2fb046ad56eafecccff26c05d8d24c53dfc
22 files changed +95 -89
src/freebsd_sysctl.c
+7 -7
@@ -936,7 +936,7 @@ int do_freebsd_sysctl(int update_every, usec_t dt) {
936
937 st = rrdset_find_localhost("system.ipc_semaphores");
938 if (unlikely(!st)) {
939 - st = rrdset_create_localhost("system", "ipc_semaphores", NULL, "ipc semaphores", NULL, "IPC Semaphores", "semaphores", 1000, rrd_update_every, RRDSET_TYPE_AREA);
939 + st = rrdset_create_localhost("system", "ipc_semaphores", NULL, "ipc semaphores", NULL, "IPC Semaphores", "semaphores", 1000, localhost->rrd_update_every, RRDSET_TYPE_AREA);
940 rrddim_add(st, "semaphores", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
941 }
942 else rrdset_next(st);
@@ -948,7 +948,7 @@ int do_freebsd_sysctl(int update_every, usec_t dt) {
948
949 st = rrdset_find_localhost("system.ipc_semaphore_arrays");
950 if (unlikely(!st)) {
951 - st = rrdset_create_localhost("system", "ipc_semaphore_arrays", NULL, "ipc semaphores", NULL, "IPC Semaphore Arrays", "arrays", 1000, rrd_update_every, RRDSET_TYPE_AREA);
951 + st = rrdset_create_localhost("system", "ipc_semaphore_arrays", NULL, "ipc semaphores", NULL, "IPC Semaphore Arrays", "arrays", 1000, localhost->rrd_update_every, RRDSET_TYPE_AREA);
952 rrddim_add(st, "arrays", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
953 }
954 else rrdset_next(st);
@@ -984,7 +984,7 @@ int do_freebsd_sysctl(int update_every, usec_t dt) {
984
985 st = rrdset_find_localhost("system.ipc_shared_mem_segs");
986 if (unlikely(!st)) {
987 - 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);
987 + 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);
988 rrddim_add(st, "segments", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
989 }
990 else rrdset_next(st);
@@ -996,7 +996,7 @@ int do_freebsd_sysctl(int update_every, usec_t dt) {
996
997 st = rrdset_find_localhost("system.ipc_shared_mem_size");
998 if (unlikely(!st)) {
999 - 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);
999 + 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);
1000 rrddim_add(st, "allocated", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE);
1001 }
1002 else rrdset_next(st);
@@ -1036,7 +1036,7 @@ int do_freebsd_sysctl(int update_every, usec_t dt) {
1036
1037 st = rrdset_find_localhost("system.ipc_msq_queues");
1038 if (unlikely(!st)) {
1039 - 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);
1039 + 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);
1040 rrddim_add(st, "queues", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
1041 }
1042 else rrdset_next(st);
@@ -1048,7 +1048,7 @@ int do_freebsd_sysctl(int update_every, usec_t dt) {
1048
1049 st = rrdset_find_localhost("system.ipc_msq_messages");
1050 if (unlikely(!st)) {
1051 - 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);
1051 + 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);
1052 rrddim_add(st, "messages", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
1053 }
1054 else rrdset_next(st);
@@ -1060,7 +1060,7 @@ int do_freebsd_sysctl(int update_every, usec_t dt) {
1060
1061 st = rrdset_find_localhost("system.ipc_msq_size");
1062 if (unlikely(!st)) {
1063 - 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);
1063 + 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);
1064 rrddim_add(st, "allocated", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
1065 rrddim_add(st, "used", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
1066 }
src/global_statistics.c
+7 -7
@@ -133,7 +133,7 @@ void global_statistics_charts(void) {
133 if (!stcpu_thread) {
134 stcpu_thread = rrdset_create_localhost("netdata", "plugin_proc_cpu", NULL, "proc", NULL
135 , "NetData Proc Plugin CPU usage", "milliseconds/s", 132000
136 - , rrd_update_every, RRDSET_TYPE_STACKED);
136 + , localhost->rrd_update_every, RRDSET_TYPE_STACKED);
137
138 rrddim_add(stcpu_thread, "user", NULL, 1, 1000, RRD_ALGORITHM_INCREMENTAL);
139 rrddim_add(stcpu_thread, "system", NULL, 1, 1000, RRD_ALGORITHM_INCREMENTAL);
@@ -148,7 +148,7 @@ void global_statistics_charts(void) {
148 if (!stcpu) stcpu = rrdset_find_localhost("netdata.server_cpu");
149 if (!stcpu) {
150 stcpu = rrdset_create_localhost("netdata", "server_cpu", NULL, "netdata", NULL, "NetData CPU usage"
151 - , "milliseconds/s", 130000, rrd_update_every, RRDSET_TYPE_STACKED);
151 + , "milliseconds/s", 130000, localhost->rrd_update_every, RRDSET_TYPE_STACKED);
152
153 rrddim_add(stcpu, "user", NULL, 1, 1000, RRD_ALGORITHM_INCREMENTAL);
154 rrddim_add(stcpu, "system", NULL, 1, 1000, RRD_ALGORITHM_INCREMENTAL);
@@ -163,7 +163,7 @@ void global_statistics_charts(void) {
163 if (!stclients) stclients = rrdset_find_localhost("netdata.clients");
164 if (!stclients) {
165 stclients = rrdset_create_localhost("netdata", "clients", NULL, "netdata", NULL, "NetData Web Clients"
166 - , "connected clients", 130200, rrd_update_every, RRDSET_TYPE_LINE);
166 + , "connected clients", 130200, localhost->rrd_update_every, RRDSET_TYPE_LINE);
167
168 rrddim_add(stclients, "clients", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
169 } else rrdset_next(stclients);
@@ -176,7 +176,7 @@ void global_statistics_charts(void) {
176 if (!streqs) streqs = rrdset_find_localhost("netdata.requests");
177 if (!streqs) {
178 streqs = rrdset_create_localhost("netdata", "requests", NULL, "netdata", NULL, "NetData Web Requests"
179 - , "requests/s", 130300, rrd_update_every, RRDSET_TYPE_LINE);
179 + , "requests/s", 130300, localhost->rrd_update_every, RRDSET_TYPE_LINE);
180
181 rrddim_add(streqs, "requests", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
182 } else rrdset_next(streqs);
@@ -189,7 +189,7 @@ void global_statistics_charts(void) {
189 if (!stbytes) stbytes = rrdset_find_localhost("netdata.net");
190 if (!stbytes) {
191 stbytes = rrdset_create_localhost("netdata", "net", NULL, "netdata", NULL, "NetData Network Traffic"
192 - , "kilobits/s", 130000, rrd_update_every, RRDSET_TYPE_AREA);
192 + , "kilobits/s", 130000, localhost->rrd_update_every, RRDSET_TYPE_AREA);
193
194 rrddim_add(stbytes, "in", NULL, 8, 1024, RRD_ALGORITHM_INCREMENTAL);
195 rrddim_add(stbytes, "out", NULL, -8, 1024, RRD_ALGORITHM_INCREMENTAL);
@@ -204,7 +204,7 @@ void global_statistics_charts(void) {
204 if (!stduration) stduration = rrdset_find_localhost("netdata.response_time");
205 if (!stduration) {
206 stduration = rrdset_create_localhost("netdata", "response_time", NULL, "netdata", NULL
207 - , "NetData API Response Time", "ms/request", 130400, rrd_update_every
207 + , "NetData API Response Time", "ms/request", 130400, localhost->rrd_update_every
208 , RRDSET_TYPE_LINE);
209
210 rrddim_add(stduration, "average", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
@@ -237,7 +237,7 @@ void global_statistics_charts(void) {
237 if (!stcompression) {
238 stcompression = rrdset_create_localhost("netdata", "compression_ratio", NULL, "netdata", NULL
239 , "NetData API Responses Compression Savings Ratio", "percentage"
240 - , 130500, rrd_update_every, RRDSET_TYPE_LINE);
240 + , 130500, localhost->rrd_update_every, RRDSET_TYPE_LINE);
241
242 rrddim_add(stcompression, "savings", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
243 } else rrdset_next(stcompression);
src/ipc.c
+2 -2
@@ -194,7 +194,7 @@ int do_ipc(int update_every, usec_t dt) {
194 semaphores = rrdset_find_localhost("system.ipc_semaphores");
195 if(!semaphores) {
196 semaphores = rrdset_create_localhost("system", "ipc_semaphores", NULL, "ipc semaphores", NULL
197 - , "IPC Semaphores", "semaphores", 1000, rrd_update_every
197 + , "IPC Semaphores", "semaphores", 1000, localhost->rrd_update_every
198 , RRDSET_TYPE_AREA);
199 rrddim_add(semaphores, "semaphores", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
200 }
@@ -202,7 +202,7 @@ int do_ipc(int update_every, usec_t dt) {
202 arrays = rrdset_find_localhost("system.ipc_semaphore_arrays");
203 if(!arrays) {
204 arrays = rrdset_create_localhost("system", "ipc_semaphore_arrays", NULL, "ipc semaphores", NULL
205 - , "IPC Semaphore Arrays", "arrays", 1000, rrd_update_every
205 + , "IPC Semaphore Arrays", "arrays", 1000, localhost->rrd_update_every
206 , RRDSET_TYPE_AREA);
207 rrddim_add(arrays, "arrays", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
208 }
src/main.c
+12 -12
@@ -443,7 +443,7 @@ int main(int argc, char **argv) {
443 char* stacksize_string = "stacksize=";
444 char* debug_flags_string = "debug_flags=";
445 if(strcmp(optarg, "unittest") == 0) {
446 - rrd_update_every = 1;
446 + default_localhost_rrd_update_every = 1;
447 if(run_all_mockup_tests()) exit(1);
448 if(unit_test_storage()) exit(1);
449 fprintf(stderr, "\n\nALL TESTS PASSED\n\n");
@@ -654,28 +654,28 @@ int main(int argc, char **argv) {
654
655 // --------------------------------------------------------------------
656
657 - rrd_default_history_entries = (int) config_get_number("global", "history", RRD_DEFAULT_HISTORY_ENTRIES);
658 - if(rrd_default_history_entries < 5 || rrd_default_history_entries > RRD_HISTORY_ENTRIES_MAX) {
659 - error("Invalid history entries %d given. Defaulting to %d.", rrd_default_history_entries, RRD_DEFAULT_HISTORY_ENTRIES);
660 - rrd_default_history_entries = RRD_DEFAULT_HISTORY_ENTRIES;
657 + default_localhost_rrd_history_entries = (int) config_get_number("global", "history", RRD_DEFAULT_HISTORY_ENTRIES);
658 + if(default_localhost_rrd_history_entries < 5 || default_localhost_rrd_history_entries > RRD_HISTORY_ENTRIES_MAX) {
659 + error("Invalid history entries %d given. Defaulting to %d.", default_localhost_rrd_history_entries, RRD_DEFAULT_HISTORY_ENTRIES);
660 + default_localhost_rrd_history_entries = RRD_DEFAULT_HISTORY_ENTRIES;
661 }
662 else {
663 - debug(D_OPTIONS, "save lines set to %d.", rrd_default_history_entries);
663 + debug(D_OPTIONS, "save lines set to %d.", default_localhost_rrd_history_entries);
664 }
665
666 // --------------------------------------------------------------------
667
668 - rrd_update_every = (int) config_get_number("global", "update every", UPDATE_EVERY);
669 - if(rrd_update_every < 1 || rrd_update_every > 600) {
670 - error("Invalid data collection frequency (update every) %d given. Defaulting to %d.", rrd_update_every, UPDATE_EVERY_MAX);
671 - rrd_update_every = UPDATE_EVERY;
668 + default_localhost_rrd_update_every = (int) config_get_number("global", "update every", UPDATE_EVERY);
669 + if(default_localhost_rrd_update_every < 1 || default_localhost_rrd_update_every > 600) {
670 + error("Invalid data collection frequency (update every) %d given. Defaulting to %d.", default_localhost_rrd_update_every, UPDATE_EVERY_MAX);
671 + default_localhost_rrd_update_every = UPDATE_EVERY;
672 }
673 - else debug(D_OPTIONS, "update timer set to %d.", rrd_update_every);
673 + else debug(D_OPTIONS, "update timer set to %d.", default_localhost_rrd_update_every);
674
675 // let the plugins know the min update_every
676 {
677 char buf[16];
678 - snprintfz(buf, 15, "%d", rrd_update_every);
678 + snprintfz(buf, 15, "%d", default_localhost_rrd_update_every);
679 setenv("NETDATA_UPDATE_EVERY", buf, 1);
680 }
681
src/plugin_checks.c
+6 -6
@@ -11,23 +11,23 @@ void *checks_main(void *ptr) {
11 if(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) != 0)
12 error("Cannot set pthread cancel state to ENABLE.");
13
14 - usec_t usec = 0, susec = rrd_update_every * USEC_PER_SEC, loop_usec = 0, total_susec = 0;
14 + usec_t usec = 0, susec = localhost->rrd_update_every * USEC_PER_SEC, loop_usec = 0, total_susec = 0;
15 struct timeval now, last, loop;
16
17 RRDSET *check1, *check2, *check3, *apps_cpu = NULL;
18
19 check1 = rrdset_create_localhost("netdata", "check1", NULL, "netdata", NULL, "Caller gives microseconds"
20 - , "a million !", 99999, rrd_update_every, RRDSET_TYPE_LINE);
20 + , "a million !", 99999, localhost->rrd_update_every, RRDSET_TYPE_LINE);
21 rrddim_add(check1, "absolute", NULL, -1, 1, RRD_ALGORITHM_ABSOLUTE);
22 rrddim_add(check1, "incremental", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
23
24 check2 = rrdset_create_localhost("netdata", "check2", NULL, "netdata", NULL, "Netdata calcs microseconds"
25 - , "a million !", 99999, rrd_update_every, RRDSET_TYPE_LINE);
25 + , "a million !", 99999, localhost->rrd_update_every, RRDSET_TYPE_LINE);
26 rrddim_add(check2, "absolute", NULL, -1, 1, RRD_ALGORITHM_ABSOLUTE);
27 rrddim_add(check2, "incremental", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
28
29 check3 = rrdset_create_localhost("netdata", "checkdt", NULL, "netdata", NULL, "Clock difference"
30 - , "microseconds diff", 99999, rrd_update_every, RRDSET_TYPE_LINE);
30 + , "microseconds diff", 99999, localhost->rrd_update_every, RRDSET_TYPE_LINE);
31 rrddim_add(check3, "caller", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
32 rrddim_add(check3, "netdata", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
33 rrddim_add(check3, "apps.plugin", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
@@ -42,8 +42,8 @@ void *checks_main(void *ptr) {
42 usec = loop_usec - susec;
43 debug(D_PROCNETDEV_LOOP, "CHECK: last loop took %llu usec (worked for %llu, sleeped for %llu).", loop_usec, usec, susec);
44
45 - if(usec < (rrd_update_every * USEC_PER_SEC / 2ULL)) susec = (rrd_update_every * USEC_PER_SEC) - usec;
46 - else susec = rrd_update_every * USEC_PER_SEC / 2ULL;
45 + if(usec < (localhost->rrd_update_every * USEC_PER_SEC / 2ULL)) susec = (localhost->rrd_update_every * USEC_PER_SEC) - usec;
46 + else susec = localhost->rrd_update_every * USEC_PER_SEC / 2ULL;
47
48 // --------------------------------------------------------------------
49 // Calculate loop time
src/plugin_freebsd.c
+2 -2
@@ -18,7 +18,7 @@ void *freebsd_main(void *ptr) {
18 // keep track of the time each module was called
19 unsigned long long sutime_freebsd_sysctl = 0ULL;
20
21 - usec_t step = rrd_update_every * USEC_PER_SEC;
21 + usec_t step = localhost->rrd_update_every * USEC_PER_SEC;
22 heartbeat_t hb;
23 heartbeat_init(&hb);
24 for(;;) {
@@ -30,7 +30,7 @@ void *freebsd_main(void *ptr) {
30
31 if(!vdo_freebsd_sysctl) {
32 debug(D_PROCNETDEV_LOOP, "FREEBSD: calling do_freebsd_sysctl().");
33 - vdo_freebsd_sysctl = do_freebsd_sysctl(rrd_update_every, hb_dt);
33 + vdo_freebsd_sysctl = do_freebsd_sysctl(localhost->rrd_update_every, hb_dt);
34 }
35 if(unlikely(netdata_exit)) break;
36
src/plugin_idlejitter.c
+2 -2
@@ -22,7 +22,7 @@ void *cpuidlejitter_main(void *ptr) {
22 RRDSET *st = rrdset_find_localhost("system.idlejitter");
23 if(!st) {
24 st = rrdset_create_localhost("system", "idlejitter", NULL, "processes", NULL, "CPU Idle Jitter"
25 - , "microseconds lost/s", 9999, rrd_update_every, RRDSET_TYPE_LINE);
25 + , "microseconds lost/s", 9999, localhost->rrd_update_every, RRDSET_TYPE_LINE);
26 rrddim_add(st, "jitter", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
27 }
28
@@ -31,7 +31,7 @@ void *cpuidlejitter_main(void *ptr) {
31 for(counter = 0; 1 ;counter++) {
32 usec_t usec = 0, susec = 0;
33
34 - while(susec < (rrd_update_every * USEC_PER_SEC)) {
34 + while(susec < (localhost->rrd_update_every * USEC_PER_SEC)) {
35
36 now_monotonic_timeval(&before);
37 sleep_usec(sleep_ms * 1000);
src/plugin_macos.c
+4 -4
@@ -22,7 +22,7 @@ void *macos_main(void *ptr) {
22 unsigned long long sutime_macos_mach_smi = 0ULL;
23 unsigned long long sutime_macos_iokit = 0ULL;
24
25 - usec_t step = rrd_update_every * USEC_PER_SEC;
25 + usec_t step = localhost->rrd_update_every * USEC_PER_SEC;
26 heartbeat_t hb;
27 heartbeat_init(&hb);
28 for(;;) {
@@ -34,19 +34,19 @@ void *macos_main(void *ptr) {
34
35 if(!vdo_macos_sysctl) {
36 debug(D_PROCNETDEV_LOOP, "MACOS: calling do_macos_sysctl().");
37 - vdo_macos_sysctl = do_macos_sysctl(rrd_update_every, hb_dt);
37 + vdo_macos_sysctl = do_macos_sysctl(localhost->rrd_update_every, hb_dt);
38 }
39 if(unlikely(netdata_exit)) break;
40
41 if(!vdo_macos_mach_smi) {
42 debug(D_PROCNETDEV_LOOP, "MACOS: calling do_macos_mach_smi().");
43 - vdo_macos_mach_smi = do_macos_mach_smi(rrd_update_every, hb_dt);
43 + vdo_macos_mach_smi = do_macos_mach_smi(localhost->rrd_update_every, hb_dt);
44 }
45 if(unlikely(netdata_exit)) break;
46
47 if(!vdo_macos_iokit) {
48 debug(D_PROCNETDEV_LOOP, "MACOS: calling do_macos_iokit().");
49 - vdo_macos_iokit = do_macos_iokit(rrd_update_every, hb_dt);
49 + vdo_macos_iokit = do_macos_iokit(localhost->rrd_update_every, hb_dt);
50 }
51 if(unlikely(netdata_exit)) break;
52
src/plugin_nfacct.c
+8 -8
@@ -128,8 +128,8 @@ void *nfacct_main(void *ptr) {
128 usec = dt_usec(&now, &last) - susec;
129 debug(D_NFACCT_LOOP, "nfacct.plugin: last loop took %llu usec (worked for %llu, sleeped for %llu).", usec + susec, usec, susec);
130
131 - if(usec < (rrd_update_every * 1000000ULL / 2ULL)) susec = (rrd_update_every * 1000000ULL) - usec;
132 - else susec = rrd_update_every * 1000000ULL / 2ULL;
131 + if(usec < (default_localhost_rrd_update_every * 1000000ULL / 2ULL)) susec = (default_localhost_rrd_update_every * 1000000ULL) - usec;
132 + else susec = default_localhost_rrd_update_every * 1000000ULL / 2ULL;
133
134
135 // --------------------------------------------------------------------
@@ -139,17 +139,17 @@ void *nfacct_main(void *ptr) {
139
140 st = rrdset_find_bytype("netfilter", "nfacct_packets");
141 if(!st) {
142 - st = rrdset_create("netfilter", "nfacct_packets", NULL, "nfacct", NULL, "Netfilter Accounting Packets", "packets/s", 3206, rrd_update_every, RRDSET_TYPE_STACKED);
142 + st = rrdset_create("netfilter", "nfacct_packets", NULL, "nfacct", NULL, "Netfilter Accounting Packets", "packets/s", 3206, default_localhost_rrd_update_every, RRDSET_TYPE_STACKED);
143
144 for(i = 0; i < nfacct_list->len ; i++)
145 - rrddim_add(st, nfacct_list->data[i].name, NULL, 1, rrd_update_every, RRD_ALGORITHM_INCREMENTAL);
145 + rrddim_add(st, nfacct_list->data[i].name, NULL, 1, default_localhost_rrd_update_every, RRD_ALGORITHM_INCREMENTAL);
146 }
147 else rrdset_next(st);
148
149 for(i = 0; i < nfacct_list->len ; i++) {
150 RRDDIM *rd = rrddim_find(st, nfacct_list->data[i].name);
151
152 - if(!rd) rd = rrddim_add(st, nfacct_list->data[i].name, NULL, 1, rrd_update_every, RRD_ALGORITHM_INCREMENTAL);
152 + if(!rd) rd = rrddim_add(st, nfacct_list->data[i].name, NULL, 1, default_localhost_rrd_update_every, RRD_ALGORITHM_INCREMENTAL);
153 if(rd) rrddim_set_by_pointer(st, rd, nfacct_list->data[i].pkts);
154 }
155
@@ -159,17 +159,17 @@ void *nfacct_main(void *ptr) {
159
160 st = rrdset_find_bytype("netfilter", "nfacct_bytes");
161 if(!st) {
162 - st = rrdset_create("netfilter", "nfacct_bytes", NULL, "nfacct", NULL, "Netfilter Accounting Bandwidth", "kilobytes/s", 3207, rrd_update_every, RRDSET_TYPE_STACKED);
162 + st = rrdset_create("netfilter", "nfacct_bytes", NULL, "nfacct", NULL, "Netfilter Accounting Bandwidth", "kilobytes/s", 3207, default_localhost_rrd_update_every, RRDSET_TYPE_STACKED);
163
164 for(i = 0; i < nfacct_list->len ; i++)
165 - rrddim_add(st, nfacct_list->data[i].name, NULL, 1, 1000 * rrd_update_every, RRD_ALGORITHM_INCREMENTAL);
165 + rrddim_add(st, nfacct_list->data[i].name, NULL, 1, 1000 * default_localhost_rrd_update_every, RRD_ALGORITHM_INCREMENTAL);
166 }
167 else rrdset_next(st);
168
169 for(i = 0; i < nfacct_list->len ; i++) {
170 RRDDIM *rd = rrddim_find(st, nfacct_list->data[i].name);
171
172 - if(!rd) rd = rrddim_add(st, nfacct_list->data[i].name, NULL, 1, 1000 * rrd_update_every, RRD_ALGORITHM_INCREMENTAL);
172 + if(!rd) rd = rrddim_add(st, nfacct_list->data[i].name, NULL, 1, 1000 * default_localhost_rrd_update_every, RRD_ALGORITHM_INCREMENTAL);
173 if(rd) rrddim_set_by_pointer(st, rd, nfacct_list->data[i].bytes);
174 }
175
src/plugin_proc.c
+3 -3
@@ -79,7 +79,7 @@ void *proc_main(void *ptr) {
79 pm->rd = NULL;
80 }
81
82 - usec_t step = rrd_update_every * USEC_PER_SEC;
82 + usec_t step = localhost->rrd_update_every * USEC_PER_SEC;
83 heartbeat_t hb;
84 heartbeat_init(&hb);
85
@@ -97,7 +97,7 @@ void *proc_main(void *ptr) {
97
98 debug(D_PROCNETDEV_LOOP, "PROC calling %s.", pm->name);
99
100 - pm->enabled = !pm->func(rrd_update_every, hb_dt);
100 + pm->enabled = !pm->func(localhost->rrd_update_every, hb_dt);
101 pm->duration = heartbeat_dt_usec(&hb) - duration;
102 duration += pm->duration;
103
@@ -117,7 +117,7 @@ void *proc_main(void *ptr) {
117 if(!st) {
118 st = rrdset_create_localhost("netdata", "plugin_proc_modules", NULL, "proc", NULL
119 , "NetData Proc Plugin Modules Durations", "milliseconds/run", 132001
120 - , rrd_update_every, RRDSET_TYPE_STACKED);
120 + , localhost->rrd_update_every, RRDSET_TYPE_STACKED);
121
122 for(i = 0 ; proc_modules[i].name ;i++) {
123 struct proc_module *pm = &proc_modules[i];
src/plugin_proc_diskspace.c
+3 -3
@@ -223,9 +223,9 @@ void *proc_diskspace_main(void *ptr) {
223
224 int vdo_cpu_netdata = config_get_boolean("plugin:proc", "netdata server resources", 1);
225
226 - int update_every = (int)config_get_number("plugin:proc:diskspace", "update every", rrd_update_every);
227 - if(update_every < rrd_update_every)
228 - update_every = rrd_update_every;
226 + int update_every = (int)config_get_number("plugin:proc:diskspace", "update every", localhost->rrd_update_every);
227 + if(update_every < localhost->rrd_update_every)
228 + update_every = localhost->rrd_update_every;
229
230 check_for_new_mountpoints_every = (int)config_get_number("plugin:proc:diskspace", "check for new mount points every", check_for_new_mountpoints_every);
231 if(check_for_new_mountpoints_every < update_every)
src/plugin_tc.c
+9 -9
@@ -376,7 +376,7 @@ static inline void tc_device_commit(struct tc_device *d) {
376 if(unlikely(!d->st_bytes))
377 d->st_bytes = rrdset_create_localhost(RRD_TYPE_TC, d->id, d->name ? d->name : d->id
378 , d->family ? d->family : d->id, RRD_TYPE_TC ".qos", "Class Usage"
379 - , "kilobits/s", 7000, rrd_update_every
379 + , "kilobits/s", 7000, localhost->rrd_update_every
380 , d->enabled_all_classes_qdiscs ? RRDSET_TYPE_LINE
381 : RRDSET_TYPE_STACKED);
382
@@ -415,7 +415,7 @@ static inline void tc_device_commit(struct tc_device *d) {
415
416 d->st_packets = rrdset_create_localhost(RRD_TYPE_TC, id, name, d->family ? d->family : d->id
417 , RRD_TYPE_TC ".qos_packets", "Class Packets", "packets/s", 7010
418 - , rrd_update_every, d->enabled_all_classes_qdiscs ? RRDSET_TYPE_LINE
418 + , localhost->rrd_update_every, d->enabled_all_classes_qdiscs ? RRDSET_TYPE_LINE
419 : RRDSET_TYPE_STACKED);
420 }
421 else {
@@ -458,7 +458,7 @@ static inline void tc_device_commit(struct tc_device *d) {
458
459 d->st_dropped = rrdset_create_localhost(RRD_TYPE_TC, id, name, d->family ? d->family : d->id
460 , RRD_TYPE_TC ".qos_dropped", "Class Dropped Packets", "packets/s"
461 - , 7020, rrd_update_every
461 + , 7020, localhost->rrd_update_every
462 , d->enabled_all_classes_qdiscs ? RRDSET_TYPE_LINE
463 : RRDSET_TYPE_STACKED);
464 }
@@ -502,7 +502,7 @@ static inline void tc_device_commit(struct tc_device *d) {
502
503 d->st_tokens = rrdset_create_localhost(RRD_TYPE_TC, id, name, d->family ? d->family : d->id
504 , RRD_TYPE_TC ".qos_tokens", "Class Tokens", "tokens", 7030
505 - , rrd_update_every, RRDSET_TYPE_LINE);
505 + , localhost->rrd_update_every, RRDSET_TYPE_LINE);
506 }
507 else {
508 rrdset_next(d->st_tokens);
@@ -545,7 +545,7 @@ static inline void tc_device_commit(struct tc_device *d) {
545
546 d->st_ctokens = rrdset_create_localhost(RRD_TYPE_TC, id, name, d->family ? d->family : d->id
547 , RRD_TYPE_TC ".qos_ctokens", "Class cTokens", "ctokens", 7040
548 - , rrd_update_every, RRDSET_TYPE_LINE);
548 + , localhost->rrd_update_every, RRDSET_TYPE_LINE);
549 }
550 else {
551 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) {
807 struct tc_device *device = NULL;
808 struct tc_class *class = NULL;
809
810 - snprintfz(buffer, TC_LINE_MAX, "exec %s %d", tc_script, rrd_update_every);
810 + snprintfz(buffer, TC_LINE_MAX, "exec %s %d", tc_script, localhost->rrd_update_every);
811 debug(D_TC_LOOP, "executing '%s'", buffer);
812
813 fp = mypopen(buffer, (pid_t *)&tc_child_pid);
@@ -992,7 +992,7 @@ void *tc_main(void *ptr) {
992 if(unlikely(!stcpu)) stcpu = rrdset_find_localhost("netdata.plugin_tc_cpu");
993 if(unlikely(!stcpu)) {
994 stcpu = rrdset_create_localhost("netdata", "plugin_tc_cpu", NULL, "tc.helper", NULL
995 - , "NetData TC CPU usage", "milliseconds/s", 135000, rrd_update_every
995 + , "NetData TC CPU usage", "milliseconds/s", 135000, localhost->rrd_update_every
996 , RRDSET_TYPE_STACKED);
997 rrddim_add(stcpu, "user", NULL, 1, 1000, RRD_ALGORITHM_INCREMENTAL);
998 rrddim_add(stcpu, "system", NULL, 1, 1000, RRD_ALGORITHM_INCREMENTAL);
@@ -1007,7 +1007,7 @@ void *tc_main(void *ptr) {
1007 if(unlikely(!sttime)) {
1008 sttime = rrdset_create_localhost("netdata", "plugin_tc_time", NULL, "tc.helper", NULL
1009 , "NetData TC script execution", "milliseconds/run", 135001
1010 - , rrd_update_every, RRDSET_TYPE_AREA);
1010 + , localhost->rrd_update_every, RRDSET_TYPE_AREA);
1011 rrddim_add(sttime, "run_time", "run time", 1, 1, RRD_ALGORITHM_ABSOLUTE);
1012 }
1013 else rrdset_next(sttime);
@@ -1056,7 +1056,7 @@ void *tc_main(void *ptr) {
1056 goto cleanup;
1057 }
1058
1059 - sleep((unsigned int) rrd_update_every);
1059 + sleep((unsigned int) localhost->rrd_update_every);
1060 }
1061
1062 cleanup:
src/plugins_d.c
+3 -3
@@ -370,8 +370,8 @@ void *pluginsd_worker_thread(void *arg) {
370 // second+ run
371 usec = dt_usec(&now, &last) - susec;
372 error("PLUGINSD: %s last loop took %llu usec (worked for %llu, sleeped for %llu).\n", cd->fullfilename, usec + susec, usec, susec);
373 - if(unlikely(usec < (rrd_update_every * USEC_PER_SEC / 2ULL))) susec = (rrd_update_every * USEC_PER_SEC) - usec;
374 - else susec = rrd_update_every * USEC_PER_SEC / 2ULL;
373 + if(unlikely(usec < (localhost->rrd_update_every * USEC_PER_SEC / 2ULL))) susec = (localhost->rrd_update_every * USEC_PER_SEC) - usec;
374 + else susec = localhost->rrd_update_every * USEC_PER_SEC / 2ULL;
375 }
376
377 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) {
526 snprintfz(cd->fullfilename, FILENAME_MAX, "%s/%s", netdata_configured_plugins_dir, cd->filename);
527
528 cd->enabled = enabled;
529 - cd->update_every = (int) config_get_number(cd->id, "update every", rrd_update_every);
529 + cd->update_every = (int) config_get_number(cd->id, "update every", localhost->rrd_update_every);
530 cd->started_t = now_realtime_sec();
531
532 char *def = "";
src/registry.c
+3 -3
@@ -326,7 +326,7 @@ void registry_statistics(void) {
326 if(!sts) sts = rrdset_find_localhost("netdata.registry_sessions");
327 if(!sts) {
328 sts = rrdset_create_localhost("netdata", "registry_sessions", NULL, "registry", NULL
329 - , "NetData Registry Sessions", "session", 131000, rrd_update_every
329 + , "NetData Registry Sessions", "session", 131000, localhost->rrd_update_every
330 , RRDSET_TYPE_LINE);
331
332 rrddim_add(sts, "sessions", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
@@ -341,7 +341,7 @@ void registry_statistics(void) {
341 if(!stc) stc = rrdset_find_localhost("netdata.registry_entries");
342 if(!stc) {
343 stc = rrdset_create_localhost("netdata", "registry_entries", NULL, "registry", NULL, "NetData Registry Entries"
344 - , "entries", 131100, rrd_update_every, RRDSET_TYPE_LINE);
344 + , "entries", 131100, localhost->rrd_update_every, RRDSET_TYPE_LINE);
345
346 rrddim_add(stc, "persons", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
347 rrddim_add(stc, "machines", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
@@ -363,7 +363,7 @@ void registry_statistics(void) {
363 if(!stm) stm = rrdset_find_localhost("netdata.registry_mem");
364 if(!stm) {
365 stm = rrdset_create_localhost("netdata", "registry_mem", NULL, "registry", NULL, "NetData Registry Memory", "KB"
366 - , 131300, rrd_update_every, RRDSET_TYPE_STACKED);
366 + , 131300, localhost->rrd_update_every, RRDSET_TYPE_STACKED);
367
368 rrddim_add(stm, "persons", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE);
369 rrddim_add(stm, "machines", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE);
src/rrd.c
+2 -2
@@ -11,8 +11,8 @@
11 int rrd_delete_unupdated_dimensions = 0;
12 */
13
14 -int rrd_update_every = UPDATE_EVERY;
15 -int rrd_default_history_entries = RRD_DEFAULT_HISTORY_ENTRIES;
14 +int default_localhost_rrd_update_every = UPDATE_EVERY;
15 +int default_localhost_rrd_history_entries = RRD_DEFAULT_HISTORY_ENTRIES;
16 RRD_MEMORY_MODE default_localhost_rrd_memory_mode = RRD_MEMORY_MODE_SAVE;
17
18
src/rrd.h
+6 -2
@@ -3,11 +3,12 @@
3
4 #define UPDATE_EVERY 1
5 #define UPDATE_EVERY_MAX 3600
6 -extern int rrd_update_every;
6
7 #define RRD_DEFAULT_HISTORY_ENTRIES 3600
8 #define RRD_HISTORY_ENTRIES_MAX (86400*10)
10 -extern int rrd_default_history_entries;
9 +
10 +extern int default_localhost_rrd_update_every;
11 +extern int default_localhost_rrd_history_entries;
12
13 #define RRD_ID_LENGTH_MAX 200
14
@@ -302,6 +303,9 @@ struct rrdhost {
303 char machine_guid[GUID_LEN + 1]; // the unique ID of this host
304 uint32_t hash_machine_guid; // the hash of the unique ID
305
306 + int rrd_update_every; // the update frequency of the host
307 + int rrd_history_entries; // the number of history entries for the host's charts
308 +
309 int health_enabled; // 1 when this host has health enabled
310 RRD_MEMORY_MODE rrd_memory_mode; // the memory more for the charts of this host
311
src/rrd2json.c
+4 -4
@@ -93,8 +93,8 @@ void rrd_stats_api_v1_charts(BUFFER *wb)
93 , localhost->hostname
94 , program_version
95 , os_type
96 - , rrd_update_every
97 - , rrd_default_history_entries
96 + , localhost->rrd_update_every
97 + , localhost->rrd_history_entries
98 );
99
100 pthread_rwlock_rdlock(&localhost->rrdset_root_rwlock);
@@ -438,8 +438,8 @@ void rrd_stats_all_json(BUFFER *wb)
438 "\t\"memory\": %lu\n"
439 "}\n"
440 , localhost->hostname
441 - , rrd_update_every
442 - , rrd_default_history_entries
441 + , localhost->rrd_update_every
442 + , localhost->rrd_history_entries
443 , memory
444 );
445 }
src/rrdhost.c
+4 -2
@@ -54,8 +54,10 @@ RRDHOST *rrdhost_create(const char *hostname, const char *guid) {
54
55 RRDHOST *host = callocz(1, sizeof(RRDHOST));
56
57 - host->rrd_memory_mode = default_localhost_rrd_memory_mode;
58 - host->health_enabled = default_localhost_health_enabled;
57 + host->rrd_update_every = default_localhost_rrd_update_every;
58 + host->rrd_history_entries = default_localhost_rrd_history_entries;
59 + host->rrd_memory_mode = default_localhost_rrd_memory_mode;
60 + host->health_enabled = default_localhost_health_enabled;
61
62 pthread_rwlock_init(&(host->rrdset_root_rwlock), NULL);
63
src/rrdset.c
+1 -1
@@ -234,7 +234,7 @@ RRDSET *rrdset_create(RRDHOST *host, const char *type, const char *id, const cha
234 return st;
235 }
236
237 - long rentries = config_get_number(fullid, "history", rrd_default_history_entries);
237 + long rentries = config_get_number(fullid, "history", host->rrd_history_entries);
238 long entries = align_entries_to_pagesize(rentries);
239 if(entries != rentries) entries = config_set_number(fullid, "history", entries);
240
src/sys_fs_cgroup.c
+3 -3
@@ -64,9 +64,9 @@ void read_cgroup_plugin_configuration() {
64 user_hash = simple_hash("user");
65 system_hash = simple_hash("system");
66
67 - cgroup_update_every = (int)config_get_number("plugin:cgroups", "update every", rrd_update_every);
68 - if(cgroup_update_every < rrd_update_every)
69 - cgroup_update_every = rrd_update_every;
67 + cgroup_update_every = (int)config_get_number("plugin:cgroups", "update every", localhost->rrd_update_every);
68 + if(cgroup_update_every < localhost->rrd_update_every)
69 + cgroup_update_every = localhost->rrd_update_every;
70
71 cgroup_check_for_new_every = (int)config_get_number("plugin:cgroups", "check for new cgroups every", cgroup_check_for_new_every * cgroup_update_every);
72 if(cgroup_check_for_new_every < cgroup_update_every)
src/unit_test.c
+2 -2
@@ -885,7 +885,7 @@ int run_test(struct test *test)
885 fprintf(stderr, "\nRunning test '%s':\n%s\n", test->name, test->description);
886
887 default_localhost_rrd_memory_mode = RRD_MEMORY_MODE_RAM;
888 - rrd_update_every = test->update_every;
888 + default_localhost_rrd_update_every = test->update_every;
889
890 char name[101];
891 snprintfz(name, 100, "unittest-%s", test->name);
@@ -1092,7 +1092,7 @@ int unit_test(long delay, long shift)
1092
1093 //debug_flags = 0xffffffff;
1094 default_localhost_rrd_memory_mode = RRD_MEMORY_MODE_RAM;
1095 - rrd_update_every = 1;
1095 + default_localhost_rrd_update_every = 1;
1096
1097 int do_abs = 1;
1098 int do_inc = 1;
src/web_client.c
+2 -2
@@ -1532,7 +1532,7 @@ int web_client_api_old_data_request(struct web_client *w, char *url, int datasou
1532 debug(D_WEB_CLIENT, "%llu: Found RRD data with name '%s'.", w->id, tok);
1533
1534 // how many entries does the client want?
1535 - int lines = rrd_default_history_entries;
1535 + int lines = (int)st->entries;
1536 int group_count = 1;
1537 time_t after = 0, before = 0;
1538 int group_method = GROUP_AVERAGE;
@@ -1934,7 +1934,7 @@ static inline void web_client_send_http_header(struct web_client *w) {
1934 // set a proper expiration date, if not already set
1935 if(unlikely(!w->response.data->expires)) {
1936 if(w->response.data->options & WB_CONTENT_NO_CACHEABLE)
1937 - w->response.data->expires = w->tv_ready.tv_sec + rrd_update_every;
1937 + w->response.data->expires = w->tv_ready.tv_sec + localhost->rrd_update_every;
1938 else
1939 w->response.data->expires = w->tv_ready.tv_sec + 86400;
1940 }