do not collect /run/user/ disk space statistics by default
Costa Tsaousis (ktsaou) committed
Oct 23, 2016 at 02:49 UTC
7ce0810bcaaf56d8eb4eb70ae4a814fd1b78a952
1 file changed
+12
-6
src/proc_diskstats.c
+12
-6
@@ -57,12 +57,6 @@ static inline void mountinfo_reload(int force) {
57
}
58
59
static inline void do_disk_space_stats(struct disk *d, const char *mount_point, const char *mount_source, const char *disk, const char *family, int update_every, unsigned long long dt) {
60
- struct statvfs buff_statvfs;
61
- if (statvfs(mount_point, &buff_statvfs) < 0) {
62
- error("Failed statvfs() for '%s' (disk '%s')", mount_point, disk);
63
- return;
64
- }
65
-
60
int do_space, do_inodes;
61
62
if(d) {
@@ -91,6 +85,9 @@ static inline void do_disk_space_stats(struct disk *d, const char *mount_point,
85
86
int def_space = CONFIG_ONDEMAND_ONDEMAND;
87
88
+ if(unlikely(strncmp(mount_point, "/run/user/", 10) == 0))
89
+ def_space = CONFIG_ONDEMAND_NO;
90
+
91
// check the user configuration (this will also show our 'on demand' decision)
92
def_space = config_get_boolean_ondemand(var_name, "enable space metrics", def_space);
93
@@ -101,6 +98,15 @@ static inline void do_disk_space_stats(struct disk *d, const char *mount_point,
98
do_inodes = config_get_boolean_ondemand(var_name, "inodes usage", ddo_inodes);
99
}
100
101
+ if(do_space == CONFIG_ONDEMAND_NO && do_inodes == CONFIG_ONDEMAND_NO)
102
+ return;
103
+
104
+ struct statvfs buff_statvfs;
105
+ if (statvfs(mount_point, &buff_statvfs) < 0) {
106
+ error("Failed statvfs() for '%s' (disk '%s')", mount_point, disk);
107
+ return;
108
+ }
109
+
110
// taken from get_fs_usage() found in coreutils
111
unsigned long bsize = (buff_statvfs.f_frsize) ? buff_statvfs.f_frsize : buff_statvfs.f_bsize;
112