]> arthur.barton.de Git - netdata.git/commitdiff
added diskspace plugin monitoring charts
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 14 Jan 2017 14:40:20 +0000 (16:40 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 14 Jan 2017 14:40:20 +0000 (16:40 +0200)
src/global_statistics.c
src/plugin_proc.c
src/plugin_proc_diskspace.c
src/sys_fs_cgroup.c

index bb2b1f08f7bf6dc6941e17766d34d39dff183627..a698615f4e770aaf9e947b1b7419f44e8a42872a 100644 (file)
@@ -131,7 +131,7 @@ void global_statistics_charts(void) {
 
     if (!stcpu_thread) stcpu_thread = rrdset_find("netdata.plugin_proc_cpu");
     if (!stcpu_thread) {
-        stcpu_thread = rrdset_create("netdata", "plugin_proc_cpu", NULL, "proc.internal", NULL,
+        stcpu_thread = rrdset_create("netdata", "plugin_proc_cpu", NULL, "proc", NULL,
                                      "NetData Proc Plugin CPU usage", "milliseconds/s", 132000, rrd_update_every,
                                      RRDSET_TYPE_STACKED);
 
index e20cbd3660cb3d24f00ad91be03204a5603524cd..9727643135b6148435fea885e9fdf01528695e85 100644 (file)
@@ -116,7 +116,7 @@ void *proc_main(void *ptr) {
                 st = rrdset_find_bytype("netdata", "plugin_proc_modules");
 
                 if(!st) {
-                    st = rrdset_create("netdata", "plugin_proc_modules", NULL, "proc.internal", NULL, "NetData Proc Plugin Modules Durations", "milliseconds/run", 132001, rrd_update_every, RRDSET_TYPE_STACKED);
+                    st = rrdset_create("netdata", "plugin_proc_modules", NULL, "proc", NULL, "NetData Proc Plugin Modules Durations", "milliseconds/run", 132001, rrd_update_every, RRDSET_TYPE_STACKED);
 
                     for(i = 0 ; proc_modules[i].name ;i++) {
                         if(unlikely(!proc_modules[i].enabled)) continue;
index 8ca5dd256edc05db1f17c3fa6a8b8561a12d312c..d2795d10ad7713d7cb6487861777963289f7bdc9 100644 (file)
@@ -176,6 +176,8 @@ void *proc_diskspace_main(void *ptr) {
     if(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) != 0)
         error("Cannot set pthread cancel state to ENABLE.");
 
+    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;
@@ -184,23 +186,34 @@ void *proc_diskspace_main(void *ptr) {
     if(check_for_new_mountpoints_every < update_every)
         check_for_new_mountpoints_every = update_every;
 
+    RRDSET *stcpu_thread = NULL, *st_duration = NULL;
+    RRDDIM *rd_user = NULL, *rd_system = NULL, *rd_duration = NULL;
+    struct rusage thread;
+
+    usec_t last = 0, dt = 0;
     usec_t step = update_every * USEC_PER_SEC;
     for(;;) {
         usec_t now = now_monotonic_usec();
         usec_t next = now - (now % step) + step;
 
+        dt = (last)?now - last:0;
+
         while(now < next) {
             sleep_usec(next - now);
             now = now_monotonic_usec();
         }
 
+        last = now;
+
         if(unlikely(netdata_exit)) break;
 
+
         // --------------------------------------------------------------------------
         // this is smart enough not to reload it every time
 
         mountinfo_reload(0);
 
+
         // --------------------------------------------------------------------------
         // disk space metrics
 
@@ -213,6 +226,55 @@ void *proc_diskspace_main(void *ptr) {
                 continue;
 
             do_disk_space_stats(mi, update_every);
+            if(unlikely(netdata_exit)) break;
+        }
+
+        if(unlikely(netdata_exit)) break;
+
+        if(vdo_cpu_netdata) {
+            // ----------------------------------------------------------------
+
+            getrusage(RUSAGE_THREAD, &thread);
+
+            if(!stcpu_thread) {
+                stcpu_thread = rrdset_find("netdata.plugin_diskspace");
+                if(!stcpu_thread) {
+                    stcpu_thread = rrdset_create("netdata", "plugin_diskspace", NULL, "diskspace", NULL
+                                                 , "NetData Disk Space Plugin CPU usage", "milliseconds/s", 132020
+                                                 , update_every, RRDSET_TYPE_STACKED);
+
+                    rd_user = rrddim_add(stcpu_thread, "user", NULL, 1, 1000, RRDDIM_INCREMENTAL);
+                    rd_system = rrddim_add(stcpu_thread, "system", NULL, 1, 1000, RRDDIM_INCREMENTAL);
+                }
+            }
+            else
+                rrdset_next(stcpu_thread);
+
+            rrddim_set_by_pointer(stcpu_thread, rd_user, thread.ru_utime.tv_sec * 1000000ULL + thread.ru_utime.tv_usec);
+            rrddim_set_by_pointer(stcpu_thread, rd_system, thread.ru_stime.tv_sec * 1000000ULL + thread.ru_stime.tv_usec);
+            rrdset_done(stcpu_thread);
+
+            // ----------------------------------------------------------------
+
+            if(!st_duration) {
+                st_duration = rrdset_find("netdata.plugin_diskspace_dt");
+                if(!st_duration) {
+                    st_duration = rrdset_create("netdata", "plugin_diskspace_dt", NULL, "diskspace", NULL
+                                                 , "NetData Disk Space Plugin Duration", "milliseconds/run", 132021
+                                                 , update_every, RRDSET_TYPE_AREA);
+
+                    rd_duration = rrddim_add(st_duration, "duration", NULL, 1, 1000, RRDDIM_ABSOLUTE);
+                }
+            }
+            else
+                rrdset_next(st_duration);
+
+            rrddim_set_by_pointer(st_duration, rd_duration, dt);
+            rrdset_done(st_duration);
+
+            // ----------------------------------------------------------------
+
+            if(unlikely(netdata_exit)) break;
         }
     }
 
index 2274c3f3cefceda30386872189ca662418747af0..5ee9d2356377978379533f77994c658a87d2e018 100644 (file)
@@ -1485,7 +1485,7 @@ void *cgroups_main(void *ptr) {
 
             if(!stcpu_thread) stcpu_thread = rrdset_find("netdata.plugin_cgroups_cpu");
             if(!stcpu_thread) {
-                stcpu_thread = rrdset_create("netdata", "plugin_cgroups_cpu", NULL, "proc.internal", NULL, "NetData CGroups Plugin CPU usage", "milliseconds/s", 132000, rrd_update_every, RRDSET_TYPE_STACKED);
+                stcpu_thread = rrdset_create("netdata", "plugin_cgroups_cpu", NULL, "cgroups", NULL, "NetData CGroups Plugin CPU usage", "milliseconds/s", 132000, rrd_update_every, RRDSET_TYPE_STACKED);
 
                 rrddim_add(stcpu_thread, "user",  NULL,  1, 1000, RRDDIM_INCREMENTAL);
                 rrddim_add(stcpu_thread, "system", NULL, 1, 1000, RRDDIM_INCREMENTAL);