Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule "Host out of inodes" triggers false positive with FAT16 on FreeBSD #398

Closed
SamK opened this issue Jan 19, 2024 · 6 comments
Closed

Comments

@SamK
Copy link

SamK commented Jan 19, 2024

Hi,

I'm monitoring my OPNsense box with Node exporter. The rule HostOutOfInodes triggers an error with this result:

{device="/dev/gpt/efiboot0", fstype="msdosfs", instance="my-opnsense-box:9100", job="node_exporter", mountpoint="/boot/efi", nodename="opn"} = 0

It should not trigger that error.
I tried to think about a generic way to resolve the query but I think the msdosfs fstype should be simply excluded from the query.

I can provide a PR.

@SamK SamK changed the title Inode alert triggers false positive with FAT32 on FreeBSD Rule "Host out of inodes" triggers false positive with FAT32 on FreeBSD Jan 19, 2024
SamK added a commit to SamK/awesome-prometheus-alerts that referenced this issue Jan 19, 2024
This commit removes the false positive alerts where a FreeBSD host
has a MS-DOS based file system mounted.

resolves samber#398
@samber
Copy link
Owner

samber commented Jan 20, 2024

Can you develop please? I'm mostly a linux+macos user. In what situation is msdosfs used?

@AnderssonPeter
Copy link

AnderssonPeter commented Jan 31, 2024

I have this exact issue on my OPNSense firewall that is freebsd based.

@SamK
Copy link
Author

SamK commented Feb 7, 2024

The FAT16 file system is used for the EFI partition.
FAT file systems do not have such thing as inodes. However FreeBSD returns a value of 512 inodes for FAT16. This is a behaviour explained in their mailing list, described by @stesser:

[...] there is no limit on the number of files (reported as inodes) in the root directory of a FAT32 file system, but such a limit does exist in FAT12/FAT16 and the default value happens to be 512 in case of FAT16.

My partition is indeed FAT16 and I am victim of this bug. ifree below should not be 0.

# df -i /boot/efi
Filesystem        1K-blocks Used  Avail Capacity iused ifree %iused  Mounted on
/dev/gpt/efiboot0    266176 1872 264304     1%     512     0  100%   /boot/efi
# file -s /dev/gpt/efiboot0
/dev/gpt/efiboot0: DOS/MBR boot sector, code offset 0x3c+2, OEM-ID "BSD4.4  ", sectors/cluster 32, root entries 512, sectors/FAT 65, sectors/track 63, heads 16, sectors 532480 (volumes > 32 MB), serial number 0xf08b1618, unlabeled, FAT (16 bit)
  • The bug is fixed in FreeBSD 13.3.
  • As of today, OPNSense 24.1 is based on FreeBSD 13.2.
  • The OPNSense roadmap has not yet scheduled to use FreeBSD 13.3.

I hope this explains the situation.

@samber, this bug will be auto-fixed in an unknown future. In the meantime a PR can easily fix it today. As the maintainer of this project it's up to you to choose what decision to take.

@SamK SamK changed the title Rule "Host out of inodes" triggers false positive with FAT32 on FreeBSD Rule "Host out of inodes" triggers false positive with FAT16 on FreeBSD Feb 7, 2024
@stesser
Copy link

stesser commented Feb 7, 2024

The MSDOSFS code in 13.3. could be backported to 13.2, but a simpler work-around would be to just return 0 for the total number of inodes (f_files). The value 0 is typically used for synthetic file systems (procfs, devfs, ...) to indicate that they do not actually use inodes (and AFAIK, monitoring systems understand this signal and ignore the inode stats).

diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c
index d7efa103581b..ba73a1f18ce4 100644
--- a/sys/fs/msdosfs/msdosfs_vfsops.c
+++ b/sys/fs/msdosfs/msdosfs_vfsops.c
@@ -950,8 +950,8 @@ msdosfs_statfs(struct mount *mp, struct statfs *sbp)
        sbp->f_blocks = pmp->pm_maxcluster + 1;
        sbp->f_bfree = pmp->pm_freeclustercount;
        sbp->f_bavail = pmp->pm_freeclustercount;
-       sbp->f_files = pmp->pm_RootDirEnts;     /* XXX */
-       sbp->f_ffree = 0;       /* what to put in here? */
+       sbp->f_files = 0;
+       sbp->f_ffree = 0;
        return (0);
 }

If this simple patch was applied to OPNSense, the "out of inodes" issue should be resolved.

(A similar patch should be applied to all synthetic file systems, some of which also reported 100% inodes used. This is fixed in 13.3 and later versions, too.)

@samber
Copy link
Owner

samber commented Feb 10, 2024

I just made a fix and prepared a revert for 2025.

@SamK
Copy link
Author

SamK commented Feb 16, 2024

The commit fixes the issue. Thank you.
I'm taking the liberty to close the issue.
Best regards.

@SamK SamK closed this as completed Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants