summaryrefslogtreecommitdiffstats
path: root/src/plugin_proc.c
diff options
context:
space:
mode:
authorFederico Ceratto <federico.ceratto@gmail.com>2017-04-30 16:09:37 +0000
committerFederico Ceratto <federico.ceratto@gmail.com>2017-04-30 16:09:37 +0000
commit51f689a8e17ff3929acd2dbf39e936d2cd3ac723 (patch)
tree92e54f543171b69dcbc639be09d11221cf96ba28 /src/plugin_proc.c
parentNew upstream version 1.5.0+dfsg (diff)
downloadnetdata-51f689a8e17ff3929acd2dbf39e936d2cd3ac723.tar.xz
netdata-51f689a8e17ff3929acd2dbf39e936d2cd3ac723.zip
New upstream version 1.6.0+dfsgupstream/1.6.0+dfsg
Diffstat (limited to 'src/plugin_proc.c')
-rw-r--r--src/plugin_proc.c34
1 files changed, 15 insertions, 19 deletions
diff --git a/src/plugin_proc.c b/src/plugin_proc.c
index 9b66b7c2..2ca77491 100644
--- a/src/plugin_proc.c
+++ b/src/plugin_proc.c
@@ -7,7 +7,6 @@ static struct proc_module {
int enabled;
int (*func)(int update_every, usec_t dt);
- usec_t last_run_usec;
usec_t duration;
RRDDIM *rd;
@@ -76,20 +75,17 @@ void *proc_main(void *ptr) {
struct proc_module *pm = &proc_modules[i];
pm->enabled = config_get_boolean("plugin:proc", pm->name, 1);
- pm->last_run_usec = 0ULL;
pm->duration = 0ULL;
pm->rd = NULL;
}
- usec_t step = rrd_update_every * USEC_PER_SEC;
- for(;;) {
- usec_t now = now_monotonic_usec();
- usec_t next = now - (now % step) + step;
+ usec_t step = localhost->rrd_update_every * USEC_PER_SEC;
+ heartbeat_t hb;
+ heartbeat_init(&hb);
- while(now < next) {
- sleep_usec(next - now);
- now = now_monotonic_usec();
- }
+ for(;;) {
+ usec_t hb_dt = heartbeat_next(&hb, step);
+ usec_t duration = 0ULL;
if(unlikely(netdata_exit)) break;
@@ -101,11 +97,9 @@ void *proc_main(void *ptr) {
debug(D_PROCNETDEV_LOOP, "PROC calling %s.", pm->name);
- pm->enabled = !pm->func(rrd_update_every, (pm->last_run_usec > 0)?now - pm->last_run_usec:0ULL);
- pm->last_run_usec = now;
-
- now = now_monotonic_usec();
- pm->duration = now - pm->last_run_usec;
+ pm->enabled = !pm->func(localhost->rrd_update_every, hb_dt);
+ pm->duration = heartbeat_dt_usec(&hb) - duration;
+ duration += pm->duration;
if(unlikely(netdata_exit)) break;
}
@@ -118,16 +112,18 @@ void *proc_main(void *ptr) {
static RRDSET *st = NULL;
if(unlikely(!st)) {
- st = rrdset_find_bytype("netdata", "plugin_proc_modules");
+ st = rrdset_find_bytype_localhost("netdata", "plugin_proc_modules");
if(!st) {
- st = rrdset_create("netdata", "plugin_proc_modules", NULL, "proc", NULL, "NetData Proc Plugin Modules Durations", "milliseconds/run", 132001, rrd_update_every, RRDSET_TYPE_STACKED);
+ st = rrdset_create_localhost("netdata", "plugin_proc_modules", NULL, "proc", NULL
+ , "NetData Proc Plugin Modules Durations", "milliseconds/run", 132001
+ , localhost->rrd_update_every, RRDSET_TYPE_STACKED);
for(i = 0 ; proc_modules[i].name ;i++) {
struct proc_module *pm = &proc_modules[i];
if(unlikely(!pm->enabled)) continue;
- pm->rd = rrddim_add(st, pm->dim, NULL, 1, 1000, RRDDIM_ABSOLUTE);
+ pm->rd = rrddim_add(st, pm->dim, NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
}
}
}
@@ -163,7 +159,7 @@ int get_numa_node_count(void)
numa_node_count = 0;
char name[FILENAME_MAX + 1];
- snprintfz(name, FILENAME_MAX, "%s%s", global_host_prefix, "/sys/devices/system/node");
+ snprintfz(name, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/devices/system/node");
char *dirname = config_get("plugin:proc:/sys/devices/system/node", "directory to monitor", name);
DIR *dir = opendir(dirname);