When I updated my CentOS system and could not mount XFS file system and my op5 Monitor did not react. I even run check_disk on these mount points but op5 Monitor did not tell me that anything was wrong. So when I managed to get the system to boot and my monitoring system tell me everything was alright I went to bed.
When I checked my email this morning I noticed that my backup script had failed and complained “file does not exist” and so on. I investigated this and found that my XFS file system was not mounted because of the missing XFS kernel module. I also looked in to why my monitor system has not warned me and figured out that check_disk check the file system you point it to and if that is not mounted it will take the parent and the thresholds for that was not reached.
After taken a look at http://www.nagiosexchange.org and found a ruby script that probably would do the job. But I do not want to install ruby on all my monitored systems, so I decided to write my own. It is written in bash and works on CentOS, and probably on most *nix systems.
The script looks in /etc/fstab and compares it with the file systems mounted. If anything is missing, return CRITICAL and the name of the missed mountpoint. The script does not check that some system file systems are mounted i.e. /proc
I have uploaded this script to nagios exchange.
#!/bin/sh
#By peter@it-slav.net
#GPLv2
RESULT=0
TMPFILE=`mktemp /tmp/mount.XXXXXXXXXX`
FSTABMOUNTS=`grep -e '^#' -v /etc/fstab|grep -v tmpfs |grep -v devpts|grep -v sysfs|grep -v proc|grep -v swap| awk '{print $2}'`
for i in $FSTABMOUNTS
do
mountpoint $i > /dev/null
if [ $? != "0" ]
then
echo -n "$i " >>$TMPFILE
RESULT=2
fi
done
#echo $RESULT
if [ $RESULT != "0" ]
then
echo "is not mounted" >> $TMPFILE
echo -n "CRITICAL: "
cat $TMPFILE
else
echo "OK: All disks mounted"
fi
rm $TMPFILE
exit $RESULT
Links:
- check_mounts.sh at Nagiosexchange
- op5 Monitor
- My other blog about the problems when I did a kernel upgrade
3 Responses to “check_mounts plugin for op5 Monitor or Nagios”
Leave a Reply
You must be logged in to post a comment.




December 29th, 2008 at 12:38 pm
thank you! this saves me a lot of work 🙂
April 20th, 2009 at 4:26 pm
when running this check, I get the following:
./check_mounts.sh: line 13: mountpoint: command not found
./check_mounts.sh: line 13: mountpoint: command not found
./check_mounts.sh: line 13: mountpoint: command not found
./check_mounts.sh: line 13: mountpoint: command not found
./check_mounts.sh: line 13: mountpoint: command not found
Any ideas?