[Nagiosplug-help] stale NFS handles detection

Ian Rarity Ian.Rarity at espc.com
Fri Feb 1 13:03:48 CET 2008

Hi Rick,

I use the following script to check for stale NFS/SMB mounts.  It's not mine; I'm sure I found it on the NagiosExchange site, but it doesn't seem to be there now.  Anyway, it does the business for me:

# Usage: check_nfs_client
# Description:
#	This script determines whether there
#	are stale NFS mounts on the host.

open  FD,">/tmp/nfsCheck";
print FD "#!/bin/bash\ncd \$1 || { exit 2; }\nexit 0;\n";
close FD;

system("chmod +x /tmp/nfsCheck");

$dirs = `mount | grep " type nfs " | awk '{print \$3}'`;
foreach $mtpt (split(/\n/,$dirs)) {
  system("/tmp/nfsCheck $mtpt &");
  system("sleep 0.3");
  chomp($proc = `ps -ef | grep nfsCheck | grep -v grep | awk '{print \$2}'`);
  if ("$proc" ne "") {
    print "NFS CRITICAL:  Stale NFS mount point - $mtpt.\n";
    system("kill -9 $proc");
    exit 2;

print "NFS OK:  All mounts available.\n";
exit 0;


Ian Rarity
Technical Engineer
ESPC (UK) Ltd.
T: (44)131 624 8000
F: (44)131 624 8509

>>> "Rick Garland" <Rick.Garland at quantum.com> 31/01/2008 19:06 >>>

Hi all

Working with Nagios 2.9 on CentOS5 and plugins 1.4.9 on RHEL4 systems.

Have had problems with stale NFS. I see lots google posts and other scripts but they don’t seem to fit the bill.

Example, on the RH systems it will not say “stale” in the df output. 

Looking for feedback. What do you use to detect stale NFS.

Private and Confidential:  This e-mail transmission is strictly 
confidential and intended solely for the addressee.  It may contain
privileged and confidential information and if you are not the 
intended recipient, you must not copy, disclose, distribute or 
take any action in reliance on it. If you have received this 
e-mail in error, please delete it and notify our E-mail Systems 
Administrator on +44 (0) 131 624 8000. ESPC (UK) Ltd does not 
accept any liability for any harm that may be caused to the 
recipient's system or data by this message or any attachment. 

ESPC (UK) Ltd is a company registered under the Companies 
Acts in Scotland (Registered Number SC203535), and having its
registered office at 90A George Street, Edinburgh, Midlothian 
EH2 3DF.

ESPC (UK) Limited is authorised and regulated by the Financial 
Services Authority.

More information about the Help mailing list