Created
February 24, 2010 22:41
-
-
Save scottwb/313971 to your computer and use it in GitHub Desktop.
Checks if NFS mount is wedged.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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