Try to detect bind mounts (#14831)
* try to detect bind mounts * minor grammar fix * remove option, skip binds by default * add check of mount_point length * add a comment * use root to compare --------- Co-authored-by: Chris Akritidis <43294513+cakrit@users.noreply.github.com>
Emmanuel Vasilakis committed
May 23, 2023 at 16:22 UTC
89f22f056ca2aae5d143da9a4e94fcab1f7ee1b8
2 files changed
+14
collectors/diskspace.plugin/README.md
+2
@@ -13,6 +13,8 @@ Simple patterns can be used to exclude mounts from showed statistics based on pa
13
14
By default, Netdata will enable monitoring metrics only when they are not zero. If they are constantly zero they are ignored. Metrics that will start having values, after Netdata is started, will be detected and charts will be automatically added to the dashboard (a refresh of the dashboard is needed for them to appear though).
15
16
+Netdata will try to detect mounts that are duplicates (i.e. from the same device), or binds, and will not display charts for them, as the device is usually already monitored.
17
+
18
To configure this plugin, you need to edit the configuration file `netdata.conf`. You can do so by using the `edit config` script.
19
20
> ### Info
collectors/proc.plugin/proc_self_mountinfo.c
+12
@@ -360,6 +360,18 @@ struct mountinfo *mountinfo_read(int do_statvfs) {
360
else {
361
mi->st_dev = 0;
362
}
363
+
364
+ //try to detect devices with same minor and major modes. Within these,
365
+ //the larger mount point is considered a bind.
366
+ struct mountinfo *mt;
367
+ for(mt = root; mt; mt = mt->next) {
368
+ if(unlikely(mt->major == mi->major && mt->minor == mi->minor && !(mi->flags & MOUNTINFO_IS_BIND))) {
369
+ if(strlen(mi->root) < strlen(mt->root))
370
+ mt->flags |= MOUNTINFO_IS_BIND;
371
+ else
372
+ mi->flags |= MOUNTINFO_IS_BIND;
373
+ }
374
+ }
375
}
376
else {
377
mi->filesystem = NULL;