added setting to disable cleaning up obsolete disks
Costa Tsaousis (ktsaou) committed
Jul 22, 2017 at 23:14 UTC
d73c4185790d35f6352b32223321f83adce187fb
2 files changed
+9
-3
src/plugin_proc_diskspace.c
+4
-1
@@ -6,6 +6,7 @@
6
7
static struct mountinfo *disk_mountinfo_root = NULL;
8
static int check_for_new_mountpoints_every = 15;
9
+static int cleanup_mount_points = 1;
10
11
static inline void mountinfo_reload(int force) {
12
static time_t last_loaded = 0;
@@ -58,7 +59,7 @@ int mount_point_cleanup(void *entry, void *data) {
59
return 0;
60
}
61
61
- if(likely(mp->collected)) {
62
+ if(likely(cleanup_mount_points && mp->collected)) {
63
mp->collected = 0;
64
mp->updated = 0;
65
mp->shown_error = 0;
@@ -328,6 +329,8 @@ void *proc_diskspace_main(void *ptr) {
329
330
int vdo_cpu_netdata = config_get_boolean("plugin:proc", "netdata server resources", 1);
331
332
+ cleanup_mount_points = config_get_boolean(CONFIG_SECTION_DISKSPACE, "remove charts of unmounted disks" , cleanup_mount_points);
333
+
334
int update_every = (int)config_get_number(CONFIG_SECTION_DISKSPACE, "update every", localhost->rrd_update_every);
335
if(update_every < localhost->rrd_update_every)
336
update_every = localhost->rrd_update_every;
src/proc_diskstats.c
+5
-2
@@ -273,7 +273,8 @@ int do_proc_diskstats(int update_every, usec_t dt) {
273
global_do_qops = CONFIG_BOOLEAN_AUTO,
274
global_do_util = CONFIG_BOOLEAN_AUTO,
275
global_do_backlog = CONFIG_BOOLEAN_AUTO,
276
- globals_initialized = 0;
276
+ globals_initialized = 0,
277
+ global_cleanup_removed_disks = 1;
278
279
if(unlikely(!globals_initialized)) {
280
globals_initialized = 1;
@@ -291,6 +292,8 @@ int do_proc_diskstats(int update_every, usec_t dt) {
292
global_do_util = config_get_boolean_ondemand(CONFIG_SECTION_DISKSTATS, "utilization percentage for all disks", global_do_util);
293
global_do_backlog = config_get_boolean_ondemand(CONFIG_SECTION_DISKSTATS, "backlog for all disks", global_do_backlog);
294
295
+ global_cleanup_removed_disks = config_get_boolean(CONFIG_SECTION_DISKSTATS, "remove charts of removed disks" , global_cleanup_removed_disks);
296
+
297
char buffer[FILENAME_MAX + 1];
298
299
snprintfz(buffer, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/dev/block/%lu:%lu/%s");
@@ -806,7 +809,7 @@ int do_proc_diskstats(int update_every, usec_t dt) {
809
810
struct disk *d = disk_root, *last = NULL;
811
while(d) {
809
- if(unlikely(!d->updated)) {
812
+ if(unlikely(global_cleanup_removed_disks && !d->updated)) {
813
struct disk *t = d;
814
815
rrdset_obsolete_and_pointer_null(d->st_avgsz);