Search Exchange
Search All Sites
Nagios Live Webinars
Let our experts show you how Nagios can help your organization.Login
Directory Tree
check mountpoints like nfs, cifs, davfs, lustre, ocf2, etc.
Meet The New Nagios Core Services Platform
Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.
Monitoring Made Magically Better
- Nagios Core on Overdrive
- Powerful Monitoring Dashboards
- Time-Saving Configuration Wizards
- Open Source Powered Monitoring On Steroids
- And So Much More!
Debian,
OpenSuse 10.1 10.2 10.3 11.0, SLES 10.1 11.1
RHEL 5 6 7 8, CentOS 5 6 7 8
Solaris
FreeBSD
# changes 2.6
# - check only dataset type filesystem on zfs
# changes 2.5
# - add -E flag to exclude path
# - add yas3fs
# changes 2.4
# - add support for ext2
# changes 2.3
# - add support for btrfs
...
See script or github for full list of changes.
Usage: $PROGNAME [-m FILE] $mountpoint [$mountpoint2 ...]
Usage: $PROGNAME -a
Usage: $PROGNAME -h,--help
Options:
-m FILE Use this mtab instead (default is /proc/mounts)
-f FILE Use this fstab instead (default is /etc/fstab)
-N NUMBER FS Field number in fstab (default: 3)
-M NUMBER Mount Field number in fstab (default: 2)
-T SECONDS Responsetime at which an NFS is declared as staled (default: 3)
-L Allow softlinks to be accepted instead of mount points
-i Ignore fstab. Don't fail just because mount isn't in fstab. (default: unset)
-a Autoselect mounts from fstab (default: unset)
-A Autoselect from fstab. Return OK if no mounts found. (default: unset)
-E PATH Use with -a or -A to exclude a path from fstab. Use '|' between paths for multiple. (default: unset)
-o When autoselecting mounts from fstab, ignore mounts having
noauto flag. (default: unset)
-w Writetest. Touch file $mountpoint/.mount_test_from_$(hostname) (default: unset)
-e ARGS Extra arguments for df (default: unset)
MOUNTPOINTS list of mountpoints to check. Ignored when -a is given
# --------------------------------------------------------------------
# now we check if the given parameters ...
# 1) ... exist in the /etc/fstab
# 2) ... are mounted
# 3) ... df -k gives no stale
# 4) ... exist on the filesystem
# 5) ... is writable (optional)
--------------------------------------------------------------------
This plugin is NOT developped by the Nagios Plugin group.
Please do not e-mail them for support on this plugin, since
they won't know what you're talking about.
For contact info, read the plugin itself...
I'm having an issue. When I run the plugin locally with -a, everything reports OK. When I run the command on nagios server via nrpe I get a CRITICAL error. Its almost like its checking for those paths on the nagios server instead of the remote host:
Nagios server:
check_nrpe -H myhost.mydomain.com -c check_mounts
CRITICAL: /mnt/testmnt doesn't exist on filesystem ;
Command from nrpe_local.cfg:
command[check_mounts]=/usr/lib/nagios/plugins/check_mountpoints.sh /mnt/testmnt
Result running command manually on remote host:
/usr/lib/nagios/plugins/check_mountpoints.sh /mnt/testmnt
OK: all mounts were found ( /mnt/testmnt )
Any ideas?
root@nfsclnt ~ # grep -i nfsserver /etc/vfstab
nfsserver:/mnt - /mnt nfs - yes rw,xattr
root@nfsclnt ~ # grep -i nfsserver /etc/mnttab
nfsserver:/mnt /mnt nfs rw,xattr,dev=9300001 1507803587
root@nfsclnt ~ # ./check_mountpoints.sh /mnt
CRITICAL: /mnt is not mounted ;
When checking shares on a remote host I get :
"(Return code of 127 is out of bounds - plugin may be missing) "
The help file does not show there is a -H option, so was wondering if you plan to implement this, or if you can tell what I am doing wrong.
The plugin is designed to be used with nrpe. So it has to be executed on the machine that is checked.
mount 1xx.26.xx.xx:/vol/e_oldlogs /geminilogs
sleep 2
mount 1xx.26.xx.xx:/vol/e_webdocs /webdocs
sleep 2
mount 1xx.26.xx.xx:/vol/e_weblogs /weblogs
I need to check agains this file for mounts is there an easy way or even a hard way to do this???
Yoo can achieve that with a little trick.
Your rc.local file needs a little rewrite.
The lines should look like that:
mount -t nfs 1xx.26.xx.xx:/vol/e_oldlogs /geminilogs
We need that "-t nfs" because the check can use the following parameters:
-f /etc/rc.local (he takes that fiel as fstab now)
-N 3 (the fieldnumber to search for FS type, thats why we needed the nfs)
-M 5 (fieldnumber of the mountpoint)
Or you can just use -i ,which ignores the fstab and just checks if the given paths are mountpoint according to mtab.
Both ways should work for you.
Regards
Tried out this and it seems to work fine. One problem though.. When I define the command like this:
command[check_mpoints]=/usr/lib/nagios/plugins/check_mountpoints.sh -a -w
And run:
/usr/lib/nagios/plugins/check_nrpe -H localhost -c check_mpoints
I'm getting "CRITICAL: /mnt/nfs/path/to/folder/.mount_test_from_hostname is not writable."
If I run it without nrpe, i.e.: /usr/lib/nagios/plugins/check_mountpoints.sh -a -w it's working fine.
Why is that? Issue with permission for the user Nagios?
Thanks,
Yes, this seems to be the problem. If the nrpe users has no write permissions, the writetest will fail.
I just tested this plugin and I have to say: this script does not what it should do (on Ubuntu 12.04)
I have a mountpoint, say /media/user/share which is defined in /etc/fstab. I ran the plugin as root and it said: "OK: all mounts were found (/media/user/share)".
Then I unmounted this share from the client,re-ran the plugin and it still claimed to be mounted: "OK: all mounts were found ( /media/user/share)".
Since Ubuntu is binary-compatibel to Debian I do really wonder why this script/plugin gives totaly wrong information (moreover, Ubuntu also uses /proc/mounts and /etc/fstab).
To put it in a nutshell: I can't blame Ubuntu for the wrong result of this plugin. I wonder how that can be, since it was updated some weeks ago :(
I will use /bin/bash -x to see if I can "debug" this script (maybe just a wrong loop logic) but consider this the reason for a low rating.
Without the bug I see on Ubuntu this would be a great plugin!
Hi ronator,
you were right, so it has nothing to do with Ubuntu or Debian. There was a bug in Release 1.14, which always returns "true" when /proc/mounts was checked. The new version 1.15 should work for you now. If not contact me via mail or github.
Regards
I added the path in version 1.12. Thanks
AIX uses /etc/filesystems instead of /etc/fstab and its a completely different format.
AIX also does not have /etc/mtab.
Thanks for the consideration.
The problem is, that i never work with AIX at all. So I am not the perfect person to implement that. If you have a tested patch I would take it so. ;)
Thanks
One other more minor annoyance is that an unknown status is returned if there are no mounts to check. An option to silence that would also be super!
Version 1.7 has the new -A flag, which returns an OK if no mount were autoread from fstab.
If you want an exclude list send me a patch ;) Time is short at the moment.
Before the while case loop I did:
MPS=`grep nfs /etc/fstab | grep -v '^#' | awk '{print $2}' | tr '\n' ' '`
then commented out the /*MPS line in the case block.
Version 1.6 adds the flag -a to the script, which means mountpoints are autoselected from fstab file.
So use the new version like:
check_mountpoints.sh -a
./check_mountpoints.sh: line 140: [: /srv/apache/etc: binary operator expected
I fixed it by quoting the variable:
if [ -z "${MPS}" ]; then
fixed in version 1.6
To use it with NRPE, do the following:
1. add the following to commands.cfg on the Nagios server:
"
# check mountpoints
define command {
command_name check_mountpoints
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c check_mountpoints -a $ARG1$ $ARG2$
}
"
2. Copy / move / download the plugin to the target server's plugin directory.
3. Adjust the NRPE config on the target server to be monitored:
#:nano /etc/nagios/nrpe.d/template.cfg
add:
"command[check_mountpoints]=/usr/lib/nagios/plugins/check_mountpoints.sh $ARG1$"
4. Restart the NRPE damon
#:/etc/init.d/nagios-nrpe-server restart
5. Add a service check on the nagios server..
NFS share is listed after mount command, but it also hangs after df -h.
Hi, your were totaly right and version 1.2 should fix that problem. The "df -k", which hangs on staled NFS mountpoints is now killed after 3 seconds or whatever time you define with -T. Try the new version.
Thanks for the reply.
CHANGES:
1. Since our mounts are CIFS, we changed all occurrences of "nfs" to "cifs".
2. Commented out section checking fstab. I would prefer to see this as a function in the script and have it be an optional check if the mount point is in fstab.
commented out:
# awk '{if ($3=="cifs"){print $2}}' /etc/fstab | grep -q ${MP} &>/dev/null
# if [ $? -ne 0 ]; then
# log "WARN: ${MP} don't exists in /etc/fstab"
# ERR_MESG[${#ERR_MESG[*]}]="${MP} don't exists in /etc/fstab"
# fi
Support for CIFS is implemented now. Should work fine.
"Unknown service Usage: check_nfs_mounts.sh [-m FILE] $NFSmountpoint [$NFSmountpoint2 ...]"
Even though after a while it displays OK status, in the next schedule the same error appears again..
I don't know what could be happened.
Please, if anyone can help me...
Try the new Version. I fixed and added alot of thinks.
X.X.X.X:/path/to/remote /path/to/local nfs4 rw,...
In the script you must to change
grep -q /proc/mounts -e " ${MP} nfs " &>/dev/null
to
grep -q /proc/mounts -e " ${MP} nfs4 " &>/dev/null
And it'll work nice for you.
The new Version 1.1 fix that. Thanks for the hint.