munin
munin copied to clipboard
df plugin working with multiple mounts of the same device
Description
When the same device is mounted multiple times (this is typical, for example, for a btrfs filesystem with multiple subvolumes, when one volume is mounted as root fs, another as /home, yet another as /opt, etc, also typical for bind mounts and in other cases), the df plugin will generate statistics for the last mount returned by df
. While usually, it is best to use the first mount of the filesystem.
This is because df
will include output for every mount point, the device which is mounted is the key - so all such mounts uses the same key, and the mountpoint is the label, - only the last label is used, each time the same device in df output is seen, overriding info for this key.
To Reproduce It is enough just to bind-mount something, for example:
mkdir -p /mnt/tst && mount --bind / /mnt/tst
After this, statistics for root fs (/) will be gone, instead, stats for /mnt/tst will be shown.
Additional context
In most cases, the first mount should be used instead of the last. So, locally, I modified df plugin to reverse output of df, including tac
into the pipe:
df $dfopts 2>/dev/null | tac |
This fixes the issue for me. An alternative is to exclude all "wrong" mounts in the config, which is not productive.