From dac6f10103d83b38fe1c20220d7396990ab12649 Mon Sep 17 00:00:00 2001 From: "Costa Tsaousis (ktsaou)" Date: Sat, 14 Jan 2017 15:53:15 +0200 Subject: [PATCH] configurable time to check for new mount points --- src/plugin_proc_diskspace.c | 11 ++++++----- src/proc_diskstats.c | 10 ++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/plugin_proc_diskspace.c b/src/plugin_proc_diskspace.c index 7e606db4..581c6c6d 100644 --- a/src/plugin_proc_diskspace.c +++ b/src/plugin_proc_diskspace.c @@ -1,18 +1,15 @@ #include "common.h" -#ifndef NETDATA_RELOAD_MOUNTINFO_EVERY -#define NETDATA_RELOAD_MOUNTINFO_EVERY 60 -#endif - #define DELAULT_EXLUDED_PATHS "/proc/ /sys/ /var/run/user/ /run/user/" static struct mountinfo *disk_mountinfo_root = NULL; +static int check_for_new_mountpoints_every = 15; static inline void mountinfo_reload(int force) { static time_t last_loaded = 0; time_t now = now_realtime_sec(); - if(force || now - last_loaded >= NETDATA_RELOAD_MOUNTINFO_EVERY) { + if(force || now - last_loaded >= check_for_new_mountpoints_every) { // mountinfo_free() can be called with NULL disk_mountinfo_root mountinfo_free(disk_mountinfo_root); @@ -186,6 +183,10 @@ void *proc_diskspace_main(void *ptr) { if(update_every < rrd_update_every) update_every = rrd_update_every; + check_for_new_mountpoints_every = (int)config_get_number("plugin:proc:diskspace", "check for new mount points every", check_for_new_mountpoints_every); + if(check_for_new_mountpoints_every < update_every) + check_for_new_mountpoints_every = update_every; + usec_t step = update_every * USEC_PER_SEC; for(;;) { usec_t now = now_monotonic_usec(); diff --git a/src/proc_diskstats.c b/src/proc_diskstats.c index 673aa9a6..ff036eb4 100644 --- a/src/proc_diskstats.c +++ b/src/proc_diskstats.c @@ -6,9 +6,7 @@ #define DISK_TYPE_PARTITION 2 #define DISK_TYPE_CONTAINER 3 -#ifndef NETDATA_RELOAD_MOUNTINFO_EVERY -#define NETDATA_RELOAD_MOUNTINFO_EVERY 60 -#endif +static int check_for_new_mountpoints_every = 15; static struct disk { char *disk; // the name of the disk (sda, sdb, etc) @@ -38,7 +36,7 @@ static inline void mountinfo_reload(int force) { static time_t last_loaded = 0; time_t now = now_realtime_sec(); - if(force || now - last_loaded >= NETDATA_RELOAD_MOUNTINFO_EVERY) { + if(force || now - last_loaded >= check_for_new_mountpoints_every) { // mountinfo_free() can be called with NULL disk_mountinfo_root mountinfo_free(disk_mountinfo_root); @@ -244,6 +242,10 @@ int do_proc_diskstats(int update_every, usec_t dt) { global_do_util = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "utilization percentage for all disks", global_do_util); global_do_backlog = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "backlog for all disks", global_do_backlog); + check_for_new_mountpoints_every = (int)config_get_number("plugin:proc:/proc/diskstats", "check for new mount points every", check_for_new_mountpoints_every); + if(check_for_new_mountpoints_every < update_every) + check_for_new_mountpoints_every = update_every; + globals_initialized = 1; } -- 2.39.2