Welcome to It-Slav.Net blog
Peter Andersson
peter@it-slav.net

I've already got a female to worry about. Her name is the Enterprise.
-- Kirk, "The Corbomite Maneuver", stardate 1514.0

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:

Share

3 Responses to “check_mounts plugin for op5 Monitor or Nagios”

  1. herman Says:

    thank you! this saves me a lot of work 🙂

  2. Mohammad Says:

    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?

  3. peter Says:

    Yes, my guess is that you do not have the command mountpoint.

    Try to run:
    # mountpoint /
    If it replyes with command not found, you probably do not have it or your $PATH is wrong.

    /PeterA

Leave a Reply


5 + = seven





Book reviews
FreePBX 2.5
Powerful Telephony Solutions






Asterisk 1.6
Build a feature rich telephony system with Asterisk






Learning NAGIOS 3.0





Cacti 0.8 Network Monitoring,
Monitor your network with ease!