NagiosEnterprises / ncpa

Nagios Cross-Platform Agent
Other
177 stars 95 forks source link

Autofs mounts not unmounting because of NCPA 2.3.1 #820

Open ashok-redd opened 2 years ago

ashok-redd commented 2 years ago

We are using NCPA 2.3.1(latest) and are observing that the auto_fs mounts are not unmounting after the expiry of timeout if NCPA processes are running. In order to force the unmounts we have to stop the NCPA listener.

However, we did a testing with NCPA 2.2.2 version and found that this issue of auto_fs mounts not unmounting doesn't arise.

We ran the following strace for both versions of NCPA strace -p

We observed that every ncpa 2.3.1 listener check(disk,cpu,memory,etc) intitiates statfs for all the mounts(including autofs) due to which the expiry of timeout never happens

The following line is left untouched after ncpa install/config:

exclude_fs_types = aufs,autofs,binfmt_misc,cifs,cgroup,configfs,debugfs,devpts,devtmpfs,encryptfs,efivarfs,fuse,fusectl,hugetlbfs,mqueue,nfs,overlayfs,proc,pstore,rpc_pipefs,securityfs,selinuxfs,smb,sysfs,tmpfs,tracefs

It can be seen that autofs is already excluded in ncpa.cfg but it doesn't seem to work.

Please help us with a fix/workaround.

MrPippin66 commented 2 years ago

This appears to be starting with the dependent package "psutil" in their disk_partitions routine.

If I pull the disk partitions with same arguments that "ncpa" uses, manually via "psutil", I also see statfs() calls being done against all the currently mounted filesystems.

And I think the core issue is that will happen for any mounted filesystem. In the case of autofs mounts, that could cause them to have their timer reset, and thus never unmount if a check is routinely run.

However, despite that I see the statfs() run, I can't find in the "psutils" package a corresponding statfs() in the linux part of the disk_partitions() routine.

That implies another dependent package from "psutils" is doing that.

But... I don't think it's causing an autofs mount in and of itself.

ccztux commented 2 years ago

You can enable or disable if all mounted partitions should be displayed with the configuration directive all_partitions in the ncpa.cfg config file:

#
#   NCPA Main Config File
#   ---------------------
#

#
# -------------------------------
# General Configuration
# -------------------------------
#

[general]

#
# Check logging (in ncpa.db and the interface) is on by default, you can disable it
# if you do not want to record the check requests that are coming in or checks being
# sent over NRDP.
# Default: check_logging = 1
#
check_logging = 1

#
# Check logging time - how long in DAYS you'd like to keep checks in the database.
# Default: 30
#
check_logging_time = 30

#
# Display all mounted disk partitions
# (essentially setting all=True here: https://psutil.readthedocs.io/en/latest/#psutil.disk_partitions)
# Default: 1
#
all_partitions = 1

#
# Excluded file system types removes these fs types from the disk metrics
# (This is mostly only noteable on UNIX systems but also works on Windows if you need it)
# Default: aufs,autofs,binfmt_misc,cifs,cgroup,configfs,debugfs,devpts,devtmpfs,
#          encryptfs,efivarfs,fuse,fusectl,hugetlbfs,mqueue,nfs,overlayfs,proc,pstore,
#          rpc_pipefs,securityfs,selinuxfs,smb,sysfs,tmpfs,tracefs
#
exclude_fs_types = aufs,autofs,binfmt_misc,cifs,cgroup,configfs,debugfs,devpts,devtmpfs,encryptfs,efivarfs,fuse,fusectl,hugetlbfs,mqueue,nfs,overlayfs,proc,pstore,rpc_pipefs,securityfs,selinuxfs,smb,sysfs,tmpfs,tracefs

Unfortunately there is a bug in the versions 2.3.x https://github.com/NagiosEnterprises/ncpa/issues/757 where setting all_partitions to 0 doesnt work. It should be fixed in the version 2.4.0.

ashok-redd commented 2 years ago

You can enable or disable if all mounted partitions should be displayed with the configuration directive all_partitions in the ncpa.cfg config file:

#
#   NCPA Main Config File
#   ---------------------
#

#
# -------------------------------
# General Configuration
# -------------------------------
#

[general]

#
# Check logging (in ncpa.db and the interface) is on by default, you can disable it
# if you do not want to record the check requests that are coming in or checks being
# sent over NRDP.
# Default: check_logging = 1
#
check_logging = 1

#
# Check logging time - how long in DAYS you'd like to keep checks in the database.
# Default: 30
#
check_logging_time = 30

#
# Display all mounted disk partitions
# (essentially setting all=True here: https://psutil.readthedocs.io/en/latest/#psutil.disk_partitions)
# Default: 1
#
all_partitions = 1

#
# Excluded file system types removes these fs types from the disk metrics
# (This is mostly only noteable on UNIX systems but also works on Windows if you need it)
# Default: aufs,autofs,binfmt_misc,cifs,cgroup,configfs,debugfs,devpts,devtmpfs,
#          encryptfs,efivarfs,fuse,fusectl,hugetlbfs,mqueue,nfs,overlayfs,proc,pstore,
#          rpc_pipefs,securityfs,selinuxfs,smb,sysfs,tmpfs,tracefs
#
exclude_fs_types = aufs,autofs,binfmt_misc,cifs,cgroup,configfs,debugfs,devpts,devtmpfs,encryptfs,efivarfs,fuse,fusectl,hugetlbfs,mqueue,nfs,overlayfs,proc,pstore,rpc_pipefs,securityfs,selinuxfs,smb,sysfs,tmpfs,tracefs

Unfortunately there is a bug in the versions 2.3.x #757 where setting all_partitions to 0 doesnt work. It should be fixed in the version 2.4.0.

Thank you. We did try the "all_partitions = 0" but as you said it didn't work as we have 2.3.1. Any ETA on the release date of 2.4.0 ? Would appreciate your quick response on ETA... :-)

ccztux commented 2 years ago

I dont know the release date of 2.4.0, but i found this: https://github.com/NagiosEnterprises/ncpa/issues/791#issuecomment-952096162