Skip to content

Commit

Permalink
Add check_mount.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Ronner committed Sep 21, 2012
1 parent dd4807c commit 880cece
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
28 changes: 28 additions & 0 deletions check_mount.sh
@@ -0,0 +1,28 @@
#!/bin/sh
# check a mountpoint by looking up /proc/mounts and stat(2)ing the directory

if [ -n "$1" ]; then
# strip last "/" if exists
MP="${1%/}"
MP_regex=$(echo ^${MP}$ | sed 's!/!\\/!g')
else
echo Usage: $0 mountpoint >&2
exit 3
fi

# if a mountpoint occurs only once in /proc/mounts returns the exit code of ls(1)
if awk '$2 ~ /'${MP_regex}'/ {print $2}' < /proc/mounts | sort | uniq -c | awk '{print $1}' | grep -q 1
then
# returns 0 on success, 1 on 'soft' error (won't happen), 2 on error
if ls -d $MP >/dev/null 2>&1; then
echo OK: ${MP} mounted and accessible
exit 0
else
echo CRITICAL: ${MP} mounted but not accessible
exit 2
fi
else
# if the mountpoint doesn't occur or occurs more than once
echo CRITICAL: ${MP} not mounted
exit 2
fi
6 changes: 6 additions & 0 deletions debian/changelog
@@ -1,3 +1,9 @@
nagios-plugins-kumina (2.10-KUMIRELEASE1) unstable; urgency=low

* Addded check_mount.

-- Thomas Ronner <thomas@kumina.nl> Fri, 21 Sep 2012 12:31:28 +0200

nagios-plugins-kumina (2.9-KUMIRELEASE1) unstable; urgency=low

* check_lsimpt:
Expand Down

0 comments on commit 880cece

Please sign in to comment.