summaryrefslogtreecommitdiffstats
path: root/collectors
diff options
context:
space:
mode:
authorEmmanuel Vasilakis <mrzammler@mm.st>2023-05-23 16:22:56 +0300
committerGitHub <noreply@github.com>2023-05-23 16:22:56 +0300
commit89f22f056ca2aae5d143da9a4e94fcab1f7ee1b8 (patch)
tree20c0c6ff0315af304928f4a842dd61526be703ba /collectors
parentc0c1e0e85a627d0509a37ea4e7ef00c2cf4aa29f (diff)
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>
Diffstat (limited to 'collectors')
-rw-r--r--collectors/diskspace.plugin/README.md2
-rw-r--r--collectors/proc.plugin/proc_self_mountinfo.c12
2 files changed, 14 insertions, 0 deletions
diff --git a/collectors/diskspace.plugin/README.md b/collectors/diskspace.plugin/README.md
index b70bbf0085..5ca1090fdd 100644
--- a/collectors/diskspace.plugin/README.md
+++ b/collectors/diskspace.plugin/README.md
@@ -13,6 +13,8 @@ Simple patterns can be used to exclude mounts from showed statistics based on pa
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).
+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.
+
To configure this plugin, you need to edit the configuration file `netdata.conf`. You can do so by using the `edit config` script.
> ### Info
diff --git a/collectors/proc.plugin/proc_self_mountinfo.c b/collectors/proc.plugin/proc_self_mountinfo.c
index 0483749c37..1947916039 100644
--- a/collectors/proc.plugin/proc_self_mountinfo.c
+++ b/collectors/proc.plugin/proc_self_mountinfo.c
@@ -360,6 +360,18 @@ struct mountinfo *mountinfo_read(int do_statvfs) {
else {
mi->st_dev = 0;
}
+
+ //try to detect devices with same minor and major modes. Within these,
+ //the larger mount point is considered a bind.
+ struct mountinfo *mt;
+ for(mt = root; mt; mt = mt->next) {
+ if(unlikely(mt->major == mi->major && mt->minor == mi->minor && !(mi->flags & MOUNTINFO_IS_BIND))) {
+ if(strlen(mi->root) < strlen(mt->root))
+ mt->flags |= MOUNTINFO_IS_BIND;
+ else
+ mi->flags |= MOUNTINFO_IS_BIND;
+ }
+ }
}
else {
mi->filesystem = NULL;