SMB

check mountpoints like nfs, cifs, davfs, lustre, ocf2, etc.

Description:

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

Compatible With

  • Nagios 3.x

License

MPL


Project Files
Project Notes
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...
Reviews (22) Add a Review
Works fine locally, but errors through nrpe
by aaplmike, July 31, 2023

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?



Awesome
by wurlog, July 31, 2020

works with btrfs over iscsi



Solaris 11
by stauraum, October 31, 2017

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 ;



Great pluign...doesnt wok on remote
by chrisb@computicket.com, June 30, 2016

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.



Works great with CIFS mount
by belgotux, June 30, 2015

For me it works great with CIFS mount on CentOS host



works great have one issue
by jkissner, May 31, 2014

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???



AIX support ?
by mv200i, February 28, 2014

I guess this plug will not work under AIX.. :o(



Not writable?
by Webkungen, October 31, 2013

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,



Not running correctly on Ubuntu (which is binary-compatible to debian)
by ronator, August 31, 2013

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!



I like.
by andreaswp, April 30, 2013

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.



AIX Support
by infecticide, October 31, 2012

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.



useful
by tomagios, October 31, 2012

the best check for mountpoints, and actively maintained! Thanks



Really useful plugin
by brigo, August 31, 2012

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!



Great plugin
by bostonsean, July 31, 2012

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.



Seems to work, but my shell complains
by arnotron, July 31, 2012

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



Working great
by deutschf3, March 31, 2012

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..



Hang
by draurdraur, September 30, 2011

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.



minor updates to make work with CIFS
by linux_samurai, July 31, 2011

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



Unknown service
by eriqut, June 30, 2011

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...



NFS v4
by nordri, March 31, 2011

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.



I made some changes, what do you think?
by hypnoz, December 31, 2010

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.



File modification needed
by momocello, September 30, 2010

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"



Add a Review

You must be logged in to submit a review.

Thank you for your review!

Your review has been submitted and is pending approval.

Recommend

To:


From:


Thank you for your recommendation!

Your recommendation has been sent.

Project Stats
Rating
4.4 (27)
Favorites
6
Views
167,031