Home Directory Plugins System Metrics File System Check if FS is Mounted (check_mount.sh) AIX, NFS, UNIX, Linux, Solaris

Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

Check if FS is Mounted (check_mount.sh) AIX, NFS, UNIX, Linux, Solaris

Current Version
1.02
Last Release Date
2018-08-21
Compatible With
  • Nagios 3.x
  • Nagios 4.x
  • Nagios XI
License
GPL
Hits
26893
Files:
FileDescription
check_mount.shcheck_mount.sh shell script
Network Monitoring Software - Download Nagios XI
Log Management Software - Nagios Log Server - Download
Netflow Analysis Software - Nagios Network Analyzer - Download
Shell Script for Nagios, checks if the FS given is mounted. Assumes that you are checking NFS by default, but it can check for any type of FS:

NFS, NFSv4, CIFS, JFS, JFS2, EXT2, EXT3, EXT4, etc (If a FS is mounted more than once it gives a Warning & reports the number of mounts).

This script do not check fstab or /etc/filesystem or other tab entries, as it is designed to consume as little CPU time as possible and to be used in different OS types.

It is a simple script, but it detects mounts of practically any type of FS, and multiple instances mounted of the same FS.

Verified compatible with the following OS:
IBM AIX v5.2-v7.2
RHEL v4.8-v6.6, RHL v9
Ubuntu v10.04-v18.04 LTS
SuSe v11
CentOS v6.5-10
CygWin v2.0.4-v2.5.1 & BusyBox v1.22.1
Oracle Solaris x86 v10-v11.3
SCO OpenServer v6.0.0
SCO UnixWare v7.1.4+, v7.1.4

Released under GPLv3. Author: Carlos Ijalba - 2016-2018.
Shell Script for Nagios, checks if the FS passed on $1 is mounted under Mount Type $2.
If no parameter passed on $2 NFS type is assumed by default.
This script do not check fstab or /etc/filesystem or other tab entries, as it is designed to consume as little CPU time as possible and to be used in different OS types.

It is a simple script, but it detects mounts of practically any type of FS, and multiple instances mounted of the same FS.

Verified compatible with the following OS:
IBM AIX v5.2-v7.2
RHEL v4.8-v6.6, RHL v9
Ubuntu v10.04-v18.04 LTS
SuSe v11
CentOS v6.5-10
CygWin v2.0.4-v2.5.1 & BusyBox v1.22.1
Oracle Solaris x86 v10-v11.3
SCO OpenServer v6.0.0
SCO UnixWare v7.1.4+, v7.1.4

Released under GPLv3, feel free to use and modify, please give credits and references when appropriate. Author: Carlos Ijalba - 2016-2018.

Alerts given to Nagios:

OK - "/exports" mounted under "NFS".
CRITICAL - "/exports" not mounted under "NFS".
WARNING - "/exports" is mounted several times! (3)

-------------

USE:
check_mount.sh [ $1 - Filesystem ] | optional: [ $2 - Type (NFS by default)]

Reports:
OK - $1 mounted under $2.
CRITICAL - $1 not mounted under $2.
WARNING - $1 is mounted several times! (number of times mounted)

Examples:
check_mount.sh /developer/logs <-- check NFS mount of /developer/logs
check_mount.sh /developer cifs <-- check CIFS mount of /developer
check_mount.sh /ora12c nfs4 <-- check NFSv4 mount of /ora12c
check_mount.sh /db2 ext3 <-- check EXT3 mount of /db2
check_mount.sh /CICS jfs2 <-- check JFS2 mount of /CICS

-------------

NAGIOS Plugin Version Control:

After the Nagios Status reported, the script shows the script's name and version, very useful to track nagios services versions and scripts invoked by a service/command.

Reviews (2)
byjamespo, December 2, 2018
Just works out of the box with minimal dependencies
bycandreasen, May 14, 2018
1 of 1 people found this review helpful
Had to modify the script as shown below so that it wouldn't alarm if one mount was a subset of another (e.g. /mnt/foo and /mnt/foo_new would alarm, saying "/mnt/foo is mounted several times (2)"

Old line 107:
MOUNTED=`mount | grep $MOUNT | grep $FS | wc -l | tr -s " "` # execute the command to check the mount...

New line 107:
MOUNTED=`mount | grep "$MOUNT" | grep " $FS " | wc -l | tr -s " "` # execute the command to check the mount...
Owner's reply

Thanks for the bug report candreasen, I have modified the script with a bug correction and added a small CPU & memory speedup.

Note that your suggested line also won't work correctly in all OS, so i have only put one space after the FS, to act as a delimiter, and removed the space before the FS.

I will post the updated script now.