configurable time to check for new mount points
Costa Tsaousis (ktsaou) committed
Jan 14, 2017 at 15:53 UTC
dac6f10103d83b38fe1c20220d7396990ab12649
2 files changed
+12
-9
src/plugin_proc_diskspace.c
+6
-5
@@ -1,18 +1,15 @@
1
#include "common.h"
2
3
-#ifndef NETDATA_RELOAD_MOUNTINFO_EVERY
4
-#define NETDATA_RELOAD_MOUNTINFO_EVERY 60
5
-#endif
6
-
3
#define DELAULT_EXLUDED_PATHS "/proc/ /sys/ /var/run/user/ /run/user/"
4
5
static struct mountinfo *disk_mountinfo_root = NULL;
6
+static int check_for_new_mountpoints_every = 15;
7
8
static inline void mountinfo_reload(int force) {
9
static time_t last_loaded = 0;
10
time_t now = now_realtime_sec();
11
15
- if(force || now - last_loaded >= NETDATA_RELOAD_MOUNTINFO_EVERY) {
12
+ if(force || now - last_loaded >= check_for_new_mountpoints_every) {
13
// mountinfo_free() can be called with NULL disk_mountinfo_root
14
mountinfo_free(disk_mountinfo_root);
15
@@ -186,6 +183,10 @@ void *proc_diskspace_main(void *ptr) {
183
if(update_every < rrd_update_every)
184
update_every = rrd_update_every;
185
186
+ check_for_new_mountpoints_every = (int)config_get_number("plugin:proc:diskspace", "check for new mount points every", check_for_new_mountpoints_every);
187
+ if(check_for_new_mountpoints_every < update_every)
188
+ check_for_new_mountpoints_every = update_every;
189
+
190
usec_t step = update_every * USEC_PER_SEC;
191
for(;;) {
192
usec_t now = now_monotonic_usec();
src/proc_diskstats.c
+6
-4
@@ -6,9 +6,7 @@
6
#define DISK_TYPE_PARTITION 2
7
#define DISK_TYPE_CONTAINER 3
8
9
-#ifndef NETDATA_RELOAD_MOUNTINFO_EVERY
10
-#define NETDATA_RELOAD_MOUNTINFO_EVERY 60
11
-#endif
9
+static int check_for_new_mountpoints_every = 15;
10
11
static struct disk {
12
char *disk; // the name of the disk (sda, sdb, etc)
@@ -38,7 +36,7 @@ static inline void mountinfo_reload(int force) {
36
static time_t last_loaded = 0;
37
time_t now = now_realtime_sec();
38
41
- if(force || now - last_loaded >= NETDATA_RELOAD_MOUNTINFO_EVERY) {
39
+ if(force || now - last_loaded >= check_for_new_mountpoints_every) {
40
// mountinfo_free() can be called with NULL disk_mountinfo_root
41
mountinfo_free(disk_mountinfo_root);
42
@@ -244,6 +242,10 @@ int do_proc_diskstats(int update_every, usec_t dt) {
242
global_do_util = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "utilization percentage for all disks", global_do_util);
243
global_do_backlog = config_get_boolean_ondemand("plugin:proc:/proc/diskstats", "backlog for all disks", global_do_backlog);
244
245
+ check_for_new_mountpoints_every = (int)config_get_number("plugin:proc:/proc/diskstats", "check for new mount points every", check_for_new_mountpoints_every);
246
+ if(check_for_new_mountpoints_every < update_every)
247
+ check_for_new_mountpoints_every = update_every;
248
+
249
globals_initialized = 1;
250
}
251