Operating System - HP-UX
1834481 Members
3895 Online
110067 Solutions
New Discussion

How to check NFS mount connectivity?

 
yyghp
Super Advisor

How to check NFS mount connectivity?

How to check NFS mount connectivity?
I have NFS mount point connecting to the NFS server. I noticed that such NFS link is not stable enough for production usage, I would like to write a cron job to monitor the connectivity of such NFS mount point.
How to check it? What kind of command is good for this verification?
And if the NFS connection is broken, how to set the "Timeout", because it may hang the process. For example, if the NFS link is dead, and I use "bdf" or "ll" command, it will hang that session.
Thanks a lot!
4 REPLIES 4
A. Clay Stephenson
Acclaimed Contributor

Re: How to check NFS mount connectivity?

Here's a fairly neat way to do this leveraging a signal handler within Perl. The idea is that a signal handler is setup to terminate a command if it receives a SIGALRM. If the command completes the alarm is cancelled.

Invoke as timeoutcmd.pl -u for usage but here's a quick example:

#!/usr/bin/sh

typeset -i STAT=0
timeoutcmd.pl -t 30 df -F nfs /xxx/yyy
STAT=${?}
if [[ ${STAT} -ne 0 ]]
then
echo "Df failed; status ${STAT}."
fi


This executes df -F nfs /xxx/yyy with a timeout of 30 seconds.


If it ain't broke, I can fix that.
Ivan Ferreira
Honored Contributor

Re: How to check NFS mount connectivity?

If you link is unreliable, use udp instead of tcp for mounting nfs directories. You can use rpcinfo -p remotehost to check the status of the nfs services, you should see rpc.mountd and rpc.nfsd.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
yyghp
Super Advisor

Re: How to check NFS mount connectivity?

is there any quick way to check the connection?
thanks!
A. Clay Stephenson
Acclaimed Contributor

Re: How to check NFS mount connectivity?

The "quick" ways hang quickly. I gave you a robust means of checking individual filesystems (or all the NFS filesystems for that matter).
If it ain't broke, I can fix that.