NFS filesystem check on Hobbit client

Matthew Epp matthew.epp at us.army.mil
Thu Jun 14 21:04:40 CEST 2007


I've written a slight mod for the filesystem check for the 
hobbitclient-sunos.sh client file. I didn't want to have an external 
script doing the NFS check, nor do I want the client hanging if the 
filesystem becomes unavailable. The difficulty is always those timeouts. 
The only command I've found (without installing something else) is the 
showmount command. It times out after 15 seconds, so that shouldn't tie 
up the Hobbit client for too long.

Can someome with a test server, they can control the shares on, run some 
tests with this code and make sure it works ok in case of a real 
failure? Note: the <tab> indicators are to be replaced by real tab 
characters since \t doesn't work with egrep for some reason.

echo "[df]"
FSTYPES=`/bin/df -n -l|awk '{print $3}'|egrep -v 
"^proc|^fd|^mntfs|^ctfs|^devfs|^objfs|^nfs"|sort|uniq`
if test "$FSTYPES" = ""; then FSTYPES="ufs"; fi
set $FSTYPES
/bin/df -F $1 -k | grep -v " /var/run"
shift
while test "$1" != ""; do
   /bin/df -F $1 -k | grep -v " /var/run" | tail +2
   shift
done
/usr/xpg4/bin/egrep '[ <tab>]nfs[ <tab>]' /etc/mnttab | 
/usr/xpg4/bin/egrep -v '[ <tab>,](ignore|indirect)[ <tab>,]' | 
/usr/bin/awk '{print $1, $2}' | while read line
do
   set -- $line
   NFSHOST=`echo $1 | /usr/bin/awk -F: '{print $1}'`
   SHARE=`echo $1 | /usr/bin/awk -F: '{print $2}'`
   /usr/sbin/ping $NFSHOST 5 >/dev/null 2>&1
   if [ $? -ne 0 ]; then
     echo "$1 IS NOT RESPONDING(ping_failed) 999% $2"
   else
     /usr/sbin/showmount -d $NFSHOST >/dev/null 2>&1
     if [ $? -ne 0 ]; then
       echo "$1 IS NOT AVAILABLE(showmount_failed) 999% $2"
     else
       /usr/sbin/showmount -d $NFSHOST | /usr/xpg4/bin/egrep "^$SHARE$" 
 >/dev/null 2>&1
       if [ $? -ne 0 ]; then
         echo "$1 IS NOT AVAILABLE(showmount_failed_to_find_share) 999% $2"
       else
         /bin/df -k $2 | tail +2
       fi
     fi
   fi
done



More information about the Xymon mailing list