summaryrefslogtreecommitdiffstats
path: root/src/proc_loadavg.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/proc_loadavg.c')
-rw-r--r--src/proc_loadavg.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/proc_loadavg.c b/src/proc_loadavg.c
index 4326ffb7d..e7863f114 100644
--- a/src/proc_loadavg.c
+++ b/src/proc_loadavg.c
@@ -6,12 +6,12 @@
int do_proc_loadavg(int update_every, usec_t dt) {
static procfile *ff = NULL;
static int do_loadavg = -1, do_all_processes = -1;
- static usec_t last_loadavg_usec = 0;
+ static usec_t next_loadavg_dt = 0;
static RRDSET *load_chart = NULL, *processes_chart = NULL;
if(unlikely(!ff)) {
char filename[FILENAME_MAX + 1];
- snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/loadavg");
+ snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/loadavg");
ff = procfile_open(config_get("plugin:proc:/proc/loadavg", "filename to monitor", filename), " \t,:|/", PROCFILE_FLAG_DEFAULT);
if(unlikely(!ff))
@@ -47,15 +47,18 @@ int do_proc_loadavg(int update_every, usec_t dt) {
// --------------------------------------------------------------------
- if(last_loadavg_usec <= dt) {
+ if(next_loadavg_dt <= dt) {
if(likely(do_loadavg)) {
if(unlikely(!load_chart)) {
- load_chart = rrdset_find_byname("system.load");
+ load_chart = rrdset_find_byname_localhost("system.load");
if(unlikely(!load_chart)) {
- load_chart = rrdset_create("system", "load", NULL, "load", NULL, "System Load Average", "load", 100, (update_every < MIN_LOADAVG_UPDATE_EVERY) ? MIN_LOADAVG_UPDATE_EVERY : update_every, RRDSET_TYPE_LINE);
- rrddim_add(load_chart, "load1", NULL, 1, 1000, RRDDIM_ABSOLUTE);
- rrddim_add(load_chart, "load5", NULL, 1, 1000, RRDDIM_ABSOLUTE);
- rrddim_add(load_chart, "load15", NULL, 1, 1000, RRDDIM_ABSOLUTE);
+ load_chart = rrdset_create_localhost("system", "load", NULL, "load", NULL, "System Load Average"
+ , "load", 100, (update_every < MIN_LOADAVG_UPDATE_EVERY)
+ ? MIN_LOADAVG_UPDATE_EVERY : update_every
+ , RRDSET_TYPE_LINE);
+ rrddim_add(load_chart, "load1", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
+ rrddim_add(load_chart, "load5", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
+ rrddim_add(load_chart, "load15", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
}
}
else
@@ -67,18 +70,20 @@ int do_proc_loadavg(int update_every, usec_t dt) {
rrdset_done(load_chart);
}
- last_loadavg_usec = load_chart->update_every * USEC_PER_SEC;
+ next_loadavg_dt = load_chart->update_every * USEC_PER_SEC;
}
- else last_loadavg_usec -= dt;
+ else next_loadavg_dt -= dt;
// --------------------------------------------------------------------
if(likely(do_all_processes)) {
if(unlikely(!processes_chart)) {
- processes_chart = rrdset_find_byname("system.active_processes");
+ processes_chart = rrdset_find_byname_localhost("system.active_processes");
if(unlikely(!processes_chart)) {
- processes_chart = rrdset_create("system", "active_processes", NULL, "processes", NULL, "System Active Processes", "processes", 750, update_every, RRDSET_TYPE_LINE);
- rrddim_add(processes_chart, "active", NULL, 1, 1, RRDDIM_ABSOLUTE);
+ processes_chart = rrdset_create_localhost("system", "active_processes", NULL, "processes", NULL
+ , "System Active Processes", "processes", 750, update_every
+ , RRDSET_TYPE_LINE);
+ rrddim_add(processes_chart, "active", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
}
}
else rrdset_next(processes_chart);