Build precise queries to find exactly what you need
Press ESC to close
Join our next live webinar: “Advanced Nagios Monitoring Techniques” – Register Now
Your review has been submitted and is pending approval.
Check if all specified nfs/cifs/davfs mounts exist and if they are correct implemented. That means we check /etc/fstab, the mountpoints in the filesystem and if they are mounted. It is written for Linux and Solaris, uses proc-Filesystem and was tested on
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.
Current Version
2.6
Last Release Date
2021-11-26
Owner
Daniel Werdermann
Download URL
https://github.com/echocat/nagios-plugin-check_mountpoints
License
MPL
Compatible With
check_mountpoints.sh
Usage: 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...
Hello! Thanks for writing this. 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?
works with btrfs over iscsi
Was is wrong here?! :-O 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 ;
Thanks for this plugin, it works great on local Nagios server. 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.
For me it works great with CIFS mount on CentOS host
I have a few servers that we ust rc.local to map NFS mounts (reasons beyound me). They look like this: 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
I guess this plug will not work under AIX.. :o(
Hi! 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.
Hello, 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 like this plugin. But I had to change LIBEXEC to include /opt/csw/libexec/nagios-plugins because i use OpenCSW-installed nagios in Solaris.
I added the path in version 1.12. Thanks
Any chance you could include AIX support? 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. ;)
the best check for mountpoints, and actively maintained! Thanks
Thank you for the plugin, which does exactly what I need. I find the '-a' option is particularly useful, but an exclusion list option to complement that would be super, as there may be some mountpoints I explicitly don't want to check. 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.
We run tons of nfs mounts across many machines and those mounts sometimes change based on needs so I made a slight modification to avoid the need to keep track of the mountpoints to provide as args. Especially since it's likely no one will tell me beforehand. 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
The check seems to work, but I get a warning for line 140, when I supply multiple mount points: ./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
Thanks, that's what I needed! 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..
If NFS is mounted, and connection to server is lost after, then script hangs. 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.
We use Windows shared folders to mount as CIFS shares on our Linux servers for backups. The below modifications where made to get it working for our CIFS mount points. Overall, the script works as advertised, and I have tested (CentOS 5) to confirm the script properly errors when mount is not attached or if folder is moved. 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.
Hi everyone, I am using this plugins and I got this error: "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.
In Debian Squeeze with NFS v4 support, partitions in /proc/mounts are show as 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.
This was a good starting point, but I think I have improved on this template, while also simplifying it. Check out my modifications. http://dpaste.de/nGQj/ One of the things I added was a reverse check, ot see if everything mounted on the system is also listed in fstab.
The link is dead :(
Nice works, I did a modification on the file to works on debian lenny. Comment #LIBEXEC="/usr/local/nagios/libexec" Replace by LIBEXEC="/usr/lib/nagios/plugins"
The new Version 1.1 fix that. Just a little late ;-) Thanks for the hint.
You must be logged in to submit a review.
To:
From: