added diskspace plugin monitoring charts
Costa Tsaousis (ktsaou) committed
Jan 14, 2017 at 16:40 UTC
f2a5d9e50e084dd71aab8b83e3b35b5d1e70c3fd
4 files changed
+65
-3
src/global_statistics.c
+1
-1
@@ -131,7 +131,7 @@ void global_statistics_charts(void) {
131
132
if (!stcpu_thread) stcpu_thread = rrdset_find("netdata.plugin_proc_cpu");
133
if (!stcpu_thread) {
134
- stcpu_thread = rrdset_create("netdata", "plugin_proc_cpu", NULL, "proc.internal", NULL,
134
+ stcpu_thread = rrdset_create("netdata", "plugin_proc_cpu", NULL, "proc", NULL,
135
"NetData Proc Plugin CPU usage", "milliseconds/s", 132000, rrd_update_every,
136
RRDSET_TYPE_STACKED);
137
src/plugin_proc.c
+1
-1
@@ -116,7 +116,7 @@ void *proc_main(void *ptr) {
116
st = rrdset_find_bytype("netdata", "plugin_proc_modules");
117
118
if(!st) {
119
- 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);
119
+ st = rrdset_create("netdata", "plugin_proc_modules", NULL, "proc", NULL, "NetData Proc Plugin Modules Durations", "milliseconds/run", 132001, rrd_update_every, RRDSET_TYPE_STACKED);
120
121
for(i = 0 ; proc_modules[i].name ;i++) {
122
if(unlikely(!proc_modules[i].enabled)) continue;
src/plugin_proc_diskspace.c
+62
@@ -176,6 +176,8 @@ void *proc_diskspace_main(void *ptr) {
176
if(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) != 0)
177
error("Cannot set pthread cancel state to ENABLE.");
178
179
+ int vdo_cpu_netdata = config_get_boolean("plugin:proc", "netdata server resources", 1);
180
+
181
int update_every = (int)config_get_number("plugin:proc:diskspace", "update every", rrd_update_every);
182
if(update_every < rrd_update_every)
183
update_every = rrd_update_every;
@@ -184,23 +186,34 @@ void *proc_diskspace_main(void *ptr) {
186
if(check_for_new_mountpoints_every < update_every)
187
check_for_new_mountpoints_every = update_every;
188
189
+ RRDSET *stcpu_thread = NULL, *st_duration = NULL;
190
+ RRDDIM *rd_user = NULL, *rd_system = NULL, *rd_duration = NULL;
191
+ struct rusage thread;
192
+
193
+ usec_t last = 0, dt = 0;
194
usec_t step = update_every * USEC_PER_SEC;
195
for(;;) {
196
usec_t now = now_monotonic_usec();
197
usec_t next = now - (now % step) + step;
198
199
+ dt = (last)?now - last:0;
200
+
201
while(now < next) {
202
sleep_usec(next - now);
203
now = now_monotonic_usec();
204
}
205
206
+ last = now;
207
+
208
if(unlikely(netdata_exit)) break;
209
210
+
211
// --------------------------------------------------------------------------
212
// this is smart enough not to reload it every time
213
214
mountinfo_reload(0);
215
216
+
217
// --------------------------------------------------------------------------
218
// disk space metrics
219
@@ -213,6 +226,55 @@ void *proc_diskspace_main(void *ptr) {
226
continue;
227
228
do_disk_space_stats(mi, update_every);
229
+ if(unlikely(netdata_exit)) break;
230
+ }
231
+
232
+ if(unlikely(netdata_exit)) break;
233
+
234
+ if(vdo_cpu_netdata) {
235
+ // ----------------------------------------------------------------
236
+
237
+ getrusage(RUSAGE_THREAD, &thread);
238
+
239
+ if(!stcpu_thread) {
240
+ stcpu_thread = rrdset_find("netdata.plugin_diskspace");
241
+ if(!stcpu_thread) {
242
+ stcpu_thread = rrdset_create("netdata", "plugin_diskspace", NULL, "diskspace", NULL
243
+ , "NetData Disk Space Plugin CPU usage", "milliseconds/s", 132020
244
+ , update_every, RRDSET_TYPE_STACKED);
245
+
246
+ rd_user = rrddim_add(stcpu_thread, "user", NULL, 1, 1000, RRDDIM_INCREMENTAL);
247
+ rd_system = rrddim_add(stcpu_thread, "system", NULL, 1, 1000, RRDDIM_INCREMENTAL);
248
+ }
249
+ }
250
+ else
251
+ rrdset_next(stcpu_thread);
252
+
253
+ rrddim_set_by_pointer(stcpu_thread, rd_user, thread.ru_utime.tv_sec * 1000000ULL + thread.ru_utime.tv_usec);
254
+ rrddim_set_by_pointer(stcpu_thread, rd_system, thread.ru_stime.tv_sec * 1000000ULL + thread.ru_stime.tv_usec);
255
+ rrdset_done(stcpu_thread);
256
+
257
+ // ----------------------------------------------------------------
258
+
259
+ if(!st_duration) {
260
+ st_duration = rrdset_find("netdata.plugin_diskspace_dt");
261
+ if(!st_duration) {
262
+ st_duration = rrdset_create("netdata", "plugin_diskspace_dt", NULL, "diskspace", NULL
263
+ , "NetData Disk Space Plugin Duration", "milliseconds/run", 132021
264
+ , update_every, RRDSET_TYPE_AREA);
265
+
266
+ rd_duration = rrddim_add(st_duration, "duration", NULL, 1, 1000, RRDDIM_ABSOLUTE);
267
+ }
268
+ }
269
+ else
270
+ rrdset_next(st_duration);
271
+
272
+ rrddim_set_by_pointer(st_duration, rd_duration, dt);
273
+ rrdset_done(st_duration);
274
+
275
+ // ----------------------------------------------------------------
276
+
277
+ if(unlikely(netdata_exit)) break;
278
}
279
}
280
src/sys_fs_cgroup.c
+1
-1
@@ -1485,7 +1485,7 @@ void *cgroups_main(void *ptr) {
1485
1486
if(!stcpu_thread) stcpu_thread = rrdset_find("netdata.plugin_cgroups_cpu");
1487
if(!stcpu_thread) {
1488
- 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);
1488
+ 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);
1489
1490
rrddim_add(stcpu_thread, "user", NULL, 1, 1000, RRDDIM_INCREMENTAL);
1491
rrddim_add(stcpu_thread, "system", NULL, 1, 1000, RRDDIM_INCREMENTAL);