September 15, 2014

Linux NFS mount time

To find mount time for any NFS mount on linux, you need to parse age value (in seconds) from /proc/self/mountstats

Below is an example entry from /proc/self/mountstats
.
.
device homedir_srv1:/volumes/home/vc/ mounted on /home1/vc with fstype nfs4 statvers=1.1
        opts:   rw,vers=4,rsize=8192,wsize=8192,namlen=255,acregmin=3,acregmax=60,acdirmin=30,acdirmax=60,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=10.12
6.32.244,minorversion=0,local_lock=none
        age:    12461348
        caps:   caps=0xffff,wtmult=512,dtsize=8192,bsize=0,namlen=255
        nfsv4:  bm0=0xfdffbfff,bm1=0xf9be3e,acl=0x3
        sec:    flavor=1,pseudoflavor=1
.
.

 Handy perl one liner, to parse/display shows all NFS mounts with their mount-time 

perl -ne 'if (/fstype nfs/) {$age=1;print ((split)[4]." ")} ; if ($age && /age/) {s/age:\s+//; print scalar localtime(time-$_)."\n";}' /proc/self/mountstats

/home1/ben Thu Apr 24 11:19:39 2014
/home1/vc  Mon Sep 15 16:37:12 2014

No comments:

Post a Comment