Skip to content

Instantly share code, notes, and snippets.

@scottwb
Created February 24, 2010 22:41
Show Gist options
  • Save scottwb/313971 to your computer and use it in GitHub Desktop.
Save scottwb/313971 to your computer and use it in GitHub Desktop.
Checks if NFS mount is wedged.
#!/bin/sh
#
# Checks to see if an NFS-mounted dir is wedged.
#
# Sometimes the NFS mount goes down. Other tactics like rpcinfo didn't
# pan out, so this hack is just based on trying to ls the mounted dir
# and timing that out if it doesn't respond quickly.
#
# Usage: check_nfs.sh <dirpath>
#
# Outputs: "ALIVE" or "DEAD".
#
#
# How many seconds to wait on the nfs mount to give up and consider it dead.
#
TIMEOUT=2
sh -c "sleep $TIMEOUT && [ `ps $$ | wc -l` == "2" ] && echo \"DEAD\" && kill $$" &
ls $1 > /dev/null
echo "ALIVE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment