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);
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);
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);
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);
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);
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);
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);
}
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);
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);
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);
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);
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);
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);
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);
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);
}
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);
}
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");
// --------------------------------------------------------------------
- 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);
}
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);
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
// 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(;;) {
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;
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);
}
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);
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(;;) {
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;
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;
// --------------------------------------------------------------------
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);
}
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);
}
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);
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;
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];
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)
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);
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 {
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);
}
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);
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);
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);
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);
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);
goto cleanup;
}
- sleep((unsigned int) rrd_update_every);
+ sleep((unsigned int) localhost->rrd_update_every);
}
cleanup:
// 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);
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 = "";
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);
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);
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);
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;
#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
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
, 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);
"\t\"memory\": %lu\n"
"}\n"
, localhost->hostname
- , rrd_update_every
- , rrd_default_history_entries
+ , localhost->rrd_update_every
+ , localhost->rrd_history_entries
, memory
);
}
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);
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);
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)
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);
//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;
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;
// 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;
}