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

RHEL7/CentOS7 check_disk autofs issue #141

Closed
biox opened this issue Feb 23, 2016 · 5 comments
Closed

RHEL7/CentOS7 check_disk autofs issue #141

biox opened this issue Feb 23, 2016 · 5 comments
Assignees
Milestone

Comments

@biox
Copy link

biox commented Feb 23, 2016

Description:
Autofs appears to mount remote autofs disks when it is run, even when the -l flag is specified. Please see this forum post for more information:
https://support.nagios.com/forum/viewtopic.php?f=35&t=37133

Reproduction:
Make an NFS server and use the following config in /etc/exports

/centos7 192.168.x.x(rw,sync,no_subtree_check,no_root_squash)

Connect a server to this NFS server using autofs. My examples is as follows.

mkdir /centos7
yum install nfs-utils autofs -y

grep cent /etc/auto.master
/- /etc/auto.centos7

cat /etc/auto.centos7
/centos7 -rw,soft,intr,rsize=8192,wsize=8192 <nfsserver>:/centos7

systemctl start autofs

umount /centos7

/usr/local/nagios/libexec/check_disk -w 2 -c 1 -l | grep cent
DISK OK - free space: / 16606 MB (92% inode=99%); /dev 478 MB (100% inode=99%); /dev/shm 488 MB (100% inode=99%); /run 482 MB (98% inode=99%); /sys/fs/cgroup 488 MB (100% inode=99%); /boot 332 MB (67% inode=99%);  run/user/0 97 MB (100% inode=99%); /centos7 14756 MB (82% inode=99%);| /=1271MB;17876 17877;0;17878 /dev=0MB;476;477;0;478 /dev/shm=0MB;486;487;0;488 /run=6MB;486;487;0;488 /sys/fs/cgroup=0MB;486;487;0;488 /boot=163MB;494;495;0;496 /run/user/0=0MB;95;96;0;97 /centos7=3161MB;17916;17917;0;17918

You can see that the check_disk command mounts the remote fileshare even though the -l flag is for checking local filesystems only. This works perfectly fine on CentOS 6.

[root@localhost ~]# umount /centos6/
[root@localhost ~]# /usr/local/nagios/libexec/check_disk -w 2 -c 1 -l | grep cent
[root@localhost ~]#
@jfrickson jfrickson added the Bug label Oct 31, 2016
@jfrickson jfrickson self-assigned this Oct 31, 2016
@jfrickson
Copy link
Contributor

I did some looking into this a couple months ago, and didn't find an obvious answer. I'll be looking again soon.

@biox
Copy link
Author

biox commented Mar 21, 2017

Thanks for the update, looking forward to a fix!

@cdawson73
Copy link

cdawson73 commented Mar 22, 2017 via email

@syl-robitaille
Copy link

We're using check_disk in an environment that makes extensive use
of autofs to mount filesystems from remote filers, and have only
recently started using *EL7. Sure enough we've encountered this
problem here, and it causes Nagios to periodically send an alert
if one of the remote filesystems happens to cross the warning or
critical thresholds ... That's not what we want in cases where we've
told check_disk to check only "local" filesystems.

I've dealt with the problem here by patching gl/mountlist.c as follows.
I can't claim to have studied check_disk itself or any other plugins
that might use ME_REMOTE extensively enough to propose that this is
the correct solution in general, but it is rather simple and gives
us exactly the result we're after here, so I decided to submit it in
case it could be useful to others. I hope it helps.

--- ./gl/mountlist.c    2014-03-04 16:41:56.000000000 -0500
+++ ./gl/mountlist.c    2017-04-03 12:43:58.813199509 -0400
@@ -214,7 +214,10 @@
 /* A file system is "remote" if its Fs_name contains a ':'
    or if (it is of type (smbfs or cifs) and its Fs_name starts with '//').  */
+/* 2017-04-04 Sylvain Robitaille (syl@encs.concordia.ca): treat
+   autofs-mounted filesystems as remote */
 # define ME_REMOTE(Fs_name, Fs_type)            \
-    (strchr (Fs_name, ':') != NULL              \
+    (strcmp (Fs_type, "autofs") == 0            \
+     || strchr (Fs_name, ':') != NULL           \
      || ((Fs_name)[0] == '/'                    \
          && (Fs_name)[1] == '/'                 \
          && (strcmp (Fs_type, "smbfs") == 0     \

--
Sylvain Robitaille

@jfrickson jfrickson added this to the next bugfix release milestone Apr 5, 2017
jfrickson pushed a commit that referenced this issue Apr 7, 2017
Fix for issue #141.
Also put in logic to skip certain system "fake" mountpoints
such as sysfs, proc, fusectl, tmpfs, etc.
@jfrickson
Copy link
Contributor

Fixed in branch maint via commit a29cd35.

Will be in release 2.2.2

@jfrickson jfrickson modified the milestones: 2.2.2, next bugfix release Apr 7, 2017
jfrickson pushed a commit that referenced this issue Apr 7, 2017
Fix for issue #141.
Also put in logic to skip certain system "fake" mountpoints
such as sysfs, proc, fusectl, tmpfs, etc.
jfrickson pushed a commit that referenced this issue May 17, 2017
Fix for issue #141.
Also put in logic to skip certain system "fake" mountpoints
such as sysfs, proc, fusectl, tmpfs, etc.
jfrickson pushed a commit that referenced this issue Jun 12, 2017
Fix for issue #141.
Also put in logic to skip certain system "fake" mountpoints
such as sysfs, proc, fusectl, tmpfs, etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants