Collectd: 5.7.1 df not capturing '/' data

Created on 4 Oct 2017  路  9Comments  路  Source: collectd/collectd

  • Version of collectd: 5.7.1

  • Operating system / distribution: RHEL 7.4

Expected behavior

Expect 'df' data for all xfs filesystems to be sent to graphite.

Actual behavior

'df' data for all xfs filesystems EXCEPT '/' are sent to graphite.

Steps to reproduce

$ grep xfs /etc/fstab
/dev/mapper/vg_root-root /                       xfs     defaults        0 0
UUID=0ed1c0ae-53ef-468c-b820-8d9acf8856a4 /boot                   xfs     defaults        0 0
/dev/mapper/vg_root-opt /opt                    xfs     defaults        0 0
/dev/mapper/vg_root-tmp /tmp                    xfs     nosuid          0 0
/dev/mapper/vg_root-var /var                    xfs     defaults        0 0
$ df -h
Filesystem                Size  Used Avail Use% Mounted on
/dev/mapper/vg_root-root  9.8G  4.7G  5.2G  48% /
devtmpfs                  902M     0  902M   0% /dev
tmpfs                     912M     0  912M   0% /dev/shm
tmpfs                     912M  8.7M  904M   1% /run
tmpfs                     912M     0  912M   0% /sys/fs/cgroup
/dev/mapper/vg_root-var    16G  2.8G   13G  18% /var
/dev/mapper/vg_root-opt   7.9G  3.1G  4.8G  39% /opt
/dev/mapper/vg_root-tmp   7.9G  756M  7.1G  10% /tmp
/dev/sda1                 847M  197M  651M  24% /boot
tmpfs                     183M     0  183M   0% /run/user/64004
tmpfs                     183M     0  183M   0% /run/user/64000



md5-abd095d1c32cf08fc10dfb04b674be66



<Plugin df>
        # Tried also with the following line added. No help.
        # MountPoint "/"
        FSType "xfs"
        IgnoreSelected false
        ReportByDevice false
        ReportReserved false
        ReportInodes false
        ValuesPercentage true
</Plugin>



md5-2da1e81613b65a708c67380c56691bd5



$ ls -l collectd
total 28
drwxr-xr-x 2 root root 4096 Sep 28 12:15 cpu-0
drwxr-xr-x 2 root root 4096 Sep 28 12:15 cpu-1
drwxr-xr-x 2 root root 4096 Oct  3 18:28 df-boot
drwxr-xr-x 2 root root 4096 Oct  3 18:28 df-opt
drwxr-xr-x 2 root root 4096 Oct  3 18:28 df-tmp
drwxr-xr-x 2 root root 4096 Oct  3 18:29 df-var
drwxr-xr-x 7 root root  121 Sep 28 12:32 disk-sda
drwxr-xr-x 7 root root   92 Sep 28 12:17 disk-sda1
drwxr-xr-x 7 root root  121 Oct  4 03:58 disk-sda2
drwxr-xr-x 7 root root  121 Sep 28 12:32 disk-sda3
drwxr-xr-x 6 root root   72 Oct  3 18:29 interface-ens192
drwxr-xr-x 3 root root   17 Sep 28 12:13 load
drwxr-xr-x 2 root root  156 Sep 28 12:13 memory
drwxr-xr-x 2 root root  111 Sep 28 12:15 swap
drwxr-xr-x 5 root root 4096 Oct  3 18:29 vmem
$
Bug Pending feedback

Most helpful comment

@jblaine @ChrisHeerschap had the same issue on RHEL 7.4 - try FSType "rootfs"
it worked for us straight away

All 9 comments

Hi @jblaine,

thanks for reporting this! Could you please provide your mtab, too? I remember that in the past the df plugin was confused by rootfs being mounted over the actual (e.g. xfs) mount.

Best regards,
鈥攐cto

For reference: #1402

rootfs / rootfs rw 0 0
...
/dev/mapper/vg_root-root / xfs rw,relatime,attr2,inode64,noquota 0 0

I'm seeing exactly this and spent a bit of time fiddling with the df plugin settings and I can get it to work _only_ if I specify MountPoint "/" - if I specify anything else, I'll get /boot and not /. This is on CentOS 7

@jblaine @ChrisHeerschap had the same issue on RHEL 7.4 - try FSType "rootfs"
it worked for us straight away

@xneo64 I tried that and confirmed it worked - hadn't thought to try that, thank you! Also works without causing problems in 6.x, so adding it across the board. Thank you!

I think this problem occurs because it is determined that /dev/mapper/vg_root-root / xfs rw,relatime,attr2,inode64,noquota 0 0 is duplicated with rootfs / rootfs rw 0 0 (both collect '/').
Therefore, '/' is not collected under conditions that specify only the line /dev/mapper/vg_root-root / xfs ~, for example the case here: FSType "xfs" or Device "/dev/mapper/vg_root-root".

I want to fix this bug. #2564 is one plan, or there is also a plan to remove "rootfs device (or filetype)" from duplication target. Which is better?

The correct fix here is to not skip a filesystem that is a duplicate of a filesystem that has been ignored. This means that if an entry in the filesystem list for "/" is ignored due to it being rootfs (and not ext4 or xfs) then later when the code comes across "/" for ext4/xfs/etc, then that entry isn't ignored. This works across other combinations too. An ignored entry in the mount list should not prevent an entry that isn't ignored.

diff --git a/src/df.c b/src/df.c
index dd90f24..e7d2019 100644
--- a/src/df.c
+++ b/src/df.c
@@ -173,12 +180,18 @@ static int df_read(void) {
     char const *dev =
         (mnt_ptr->spec_device != NULL) ? mnt_ptr->spec_device : mnt_ptr->device;

-    if (ignorelist_match(il_device, dev))
+    if (ignorelist_match(il_device, dev)) {
+      mnt_ptr->ignored = 1;
       continue;
-    if (ignorelist_match(il_mountpoint, mnt_ptr->dir))
+    }
+    if (ignorelist_match(il_mountpoint, mnt_ptr->dir)) {
+      mnt_ptr->ignored = 1;
       continue;
-    if (ignorelist_match(il_fstype, mnt_ptr->type))
+    }
+    if (ignorelist_match(il_fstype, mnt_ptr->type)) {
+      mnt_ptr->ignored = 1;
       continue;
+    }

     /* search for duplicates *in front of* the current mnt_ptr. */
     for (dup_ptr = mnt_list; dup_ptr != NULL; dup_ptr = dup_ptr->next) {
@@ -188,6 +201,8 @@ static int df_read(void) {
         dup_ptr = NULL;
         break;
       }
+      if (dup_ptr->ignored == 1)
+        continue;

       /* Duplicate found: leave non-NULL dup_ptr. */
       if (by_device && (mnt_ptr->spec_device != NULL) &&
diff --git a/src/utils_mount.h b/src/utils_mount.h
index 0ad7d02..fd62c09 100644
--- a/src/utils_mount.h
+++ b/src/utils_mount.h
@@ -82,6 +82,7 @@ struct _cu_mount_t {
   char *device;      /* "none" or "proc" or "/dev/hda1" */
   char *type;        /* "sysfs" or "ext3" */
   char *options;     /* "rw,noatime,commit=600,quota,grpquota" */
+  int  ignored;
   cu_mount_t *next;
 };

Was this page helpful?
0 / 5 - 0 ratings