[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
NFS filesystem check on Hobbit client
- To: hobbit (at) hswn.dk
 
- Subject: NFS filesystem check on Hobbit client
 
- From: Matthew Epp <matthew.epp (at) us.army.mil>
 
- Date: Thu, 14 Jun 2007 15:04:40 -0400
 
- Domainkey-signature: s=ako; d=us.army.mil; c=nofws; q=dns; b=Lc9dQ17EJKLmurmMF+ItBi0tpGoXulxMrtg0HsRBAJamzbTLTmSmDbaTB7luMoeZt69abQI9WeL8CKsNs24DZQ==;
 
- References: <46700419.8040302 (at) steria.com> <199afa060706130844u530ed66m43a438eafe8b4b18 (at) mail.gmail.com> <46715589.3030906 (at) steria.com>
 
- User-agent: Thunderbird 1.5.0.12 (Windows/20070509)
 
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