Table of Contents
In this article, I will take you through 10 Popular nfsstat command examples which can be used by Linux Professionals to check the NFS statistics . If you are using NFS(Network File System) Server in your Organization and facing slowness and other NFS issues then you might want to use nfsstat command to troubleshoot those issues. nfsstat command is used for displaying NFS and RPC Connection Statistics. This tool can be used to display Statistics from both Server as well as from the Client Side. I will explain you the different usages of nfsstat command in Linux with the help of various examples.
Synopsis
nfsstat [OPTION]…
nfsstat command examples in Linux
Also Read: Top 20 Elasticsearch API Query for Developers Part – 1
Example 1: How to check nfsstat command version in Linux
If you want to check nfsstat command version then you need to use nfsstat --version
command as shown below. As you can see from below output currently installed nfsstat version is 1.3.3
.
root@localhost:~# nfsstat --version nfsstat: 1.3.3
–version : Show program version. More on nfsstat command Man Page.
Example 2: How to Check NFS Client Statistics in Linux
If you want to check NFS Client Statistics then you need to use nfsstat -c
command as shown below. From the below output you need to check few of the important parameters like retrans
which provide information about retransmission rate. If the retransmission rate is above 0 then client requests are not getting served from NFS Server as RPC are synchronous. Until you have a client request served next client request is blocked from the Server. Hence client will retransmit the request for a specified number of times until it finally quits.
You can find more information about the other output parameters below.
- calls : Total Number of RPC Calls made.
- retrans : The number of times a call had to be retransmitted due to a time-out while waiting for a reply from the server.
- authrefrsh: The number of times the NFS client has called call_refresh() which is basically going out to the RPC server (portmap, rpcbind, etc) and validating its credentials with the server.
- null : do nothing (debug). Check this IETF RFC Document to know more about this.
- read : read from file. Check this IETF RFC Document to know more about this.
- write : write to file
- commit : commit cached data to stable storage
- open : open a file
- open_conf : Confirm Open
- open_noat : Open Named Attribute Directory
- open_dgrd : Reduce Open File Access
- close : Close File
- setattr : set file attributes
- fsinfo : get static file system information
- renew : renew a lease
- setclntid : Negotiate Client ID
- lock : Create Lock
- lockt : Test For Lock
- locku : lookup file name
- access : check access permission
- getattr : get file attributes
- lookup : Lookup Filename
- remove : Remove a File
- rename : Rename a File or Directory
- link : Create Link to an Object
- symlink : Create a Symbolic Link
- create : Create a File
- pathconf : Retrieve POSIX Information
- readlink : Read from Symbolic Link
- readdir : Read from Directory
- delegreturn : Return Delegations
- getacl : Get Access List
- setacl : Set Access List
- fs_locations : Locations where this file system may be found.
- secinfo : obtain available security
- exchange_id : Instantiate Client ID
- create_ses : creation new session and confirm Client ID
- destroy_ses : destroy session
- sequence : Supply Per-Procedure
- reclaim_comp : Indicates Reclaim Finished.
- layoutget : Get Layout Information
- getdevinfo : Get Device Information
- layoutcommit : Commit Writes Made
- layoutreturn : Release Layout
- getdevlist : Get All Devices
[root@localhost ~]# nfsstat -c Client rpc stats: calls retrans authrefrsh 45 0 45 Client nfs v4: null read write commit open open_conf 0 0% 0 0% 0 0% 0 0% 0 0% 0 0% open_noat open_dgrd close setattr fsinfo renew 0 0% 0 0% 0 0% 0 0% 3 6% 0 0% setclntid confirm lock lockt locku access 0 0% 0 0% 0 0% 0 0% 0 0% 2 4% getattr lookup lookup_root remove rename link 2 4% 3 6% 1 2% 0 0% 0 0% 0 0% symlink create pathconf statfs readlink readdir 0 0% 0 0% 2 4% 0 0% 0 0% 0 0% server_caps delegreturn getacl setacl fs_locations rel_lkowner 5 11% 0 0% 0 0% 0 0% 0 0% 0 0% secinfo exchange_id create_ses destroy_ses sequence get_lease_t 0 0% 0 0% 1 2% 1 2% 0 0% 22 50% reclaim_comp layoutget getdevinfo layoutcommit layoutreturn getdevlist 0 0% 1 2% 0 0% 0 0% 0 0% 0 0% (null) 1 2%
-c : Show NFS client statistics. More on nfsstat command Man Page.
Example 3: How to Check NFS Server Statistics in Linux
If you want to check NFS Server Statistics in Linux then you need to use nfsstat -s
command as shown below. Below are few important output parameters which needs to be checked for any observed NFS issues. If you see badcalls
parameter value above 0, then you need to check the connection between NFS Server and Client for any possible Latency.
- calls : Total number of RPC Calls Received.
- badcalls : Total number of calls rejected by the RPC layer.
- badfmt : Most Bad Calls. Check this link to know more about this.
- badauth : Bad Authentication
- badclnt : Unused
root@localhost:~# nfsstat -s Server rpc stats: calls badcalls badfmt badauth badclnt 45 0 0 0 0 Server nfs v4: null compound 1 2% 44 97% Server nfs v4 operations: op0-unused op1-unused op2-future access close 0 0% 0 0% 0 0% 2 2% 0 0% commit create delegpurge delegreturn getattr 0 0% 0 0% 0 0% 0 0% 18 19% getfh link lock lockt locku 4 4% 0 0% 0 0% 0 0% 0 0% lookup lookup_root nverify open openattr 3 3% 0 0% 0 0% 0 0% 0 0% open_conf open_dgrd putfh putpubfh putrootfh 0 0% 0 0% 17 18% 0 0% 2 2% read readdir readlink remove rename 0 0% 0 0% 0 0% 0 0% 0 0% renew restorefh savefh secinfo setattr 0 0% 0 0% 0 0% 0 0% 0 0% setcltid setcltidconf verify write rellockowner 0 0% 0 0% 0 0% 0 0% 0 0% bc_ctl bind_conn exchange_id create_ses destroy_ses 0 0% 0 0% 1 1% 1 1% 0 0% free_stateid getdirdeleg getdevinfo getdevlist layoutcommit 0 0% 0 0% 0 0% 0 0% 0 0% layoutget layoutreturn secinfononam sequence set_ssv 0 0% 0 0% 1 1% 42 45% 0 0% test_stateid want_deleg destroy_clid reclaim_comp allocate 0 0% 0 0% 0 0% 1 1% 0 0% copy copy_notify deallocate ioadvise layouterror 0 0% 0 0% 0 0% 0 0% 0 0% layoutstats offloadcancel offloadstatus readplus seek 0 0% 0 0% 0 0% 0 0% 0 0% write_same 0 0%
-s : Show NFS server statistics. More on nfsstat command Man Page.
Example 4: How to Display Information about mounted NFS File systems
If you want to display all the information about mounted NFS File systems then you need to use nfsstat -m
command as shown below. Here 192.168.0.108
is our NFS Server which has /mnt/nfs
directory shared and the same is mounted on our Client System(192.168.0.103)
over /nfsclient
mount point as shown in the output.
[root@localhost ~]# nfsstat -m /nfsclient from 192.168.0.108:/mnt/nfs Flags: rw,relatime,vers=4.1,rsize=262144,wsize=262144,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.0.103,local_lock=none,addr=192.168.0.108
-m : Show statistics on mounted NFS filesystems. More on nfsstat command Man Page.
Example 5: How to Display RPC Statistics in Linux
NFS(Network File System) uses RPC Layer to route communications between NFS Server and client so if you want to show only RPC statistics then you need to use nfsstat -r
command as shown below. By default running nfsstat command will show you both RPC as well as NFS Stats.
[root@localhost ~]# nfsstat -r Client rpc stats: calls retrans authrefrsh 50 0 50
-r : Show RPC statistics. More on nfsstat command Man Page.
Example 6: How to Display NFS Statistics in Linux
By default nfsstat command will show both NFS and RPC statistics. If you want to check only NFS Statistics then you need to use nfsstat -n
command as shown below.
[root@localhost ~]# nfsstat -n Client nfs v4: null read write commit open open_conf 0 0% 0 0% 0 0% 0 0% 0 0% 0 0% open_noat open_dgrd close setattr fsinfo renew 0 0% 0 0% 0 0% 0 0% 3 5% 0 0% setclntid confirm lock lockt locku access 0 0% 0 0% 0 0% 0 0% 0 0% 2 3% getattr lookup lookup_root remove rename link 2 3% 3 5% 1 1% 0 0% 0 0% 0 0% symlink create pathconf statfs readlink readdir 0 0% 0 0% 2 3% 0 0% 0 0% 0 0% server_caps delegreturn getacl setacl fs_locations rel_lkowner 5 9% 0 0% 0 0% 0 0% 0 0% 0 0% secinfo exchange_id create_ses destroy_ses sequence get_lease_t 0 0% 0 0% 1 1% 1 1% 0 0% 30 57% reclaim_comp layoutget getdevinfo layoutcommit layoutreturn getdevlist 0 0% 1 1% 0 0% 0 0% 0 0% 0 0% (null) 1 1%
-n : Show NFS statistics. More on nfsstat command Man Page.
Example 7: How to Show all Information about all version of NFS
If you want to show all the information about NFS version 2, 3 and 4 then you need to use nfsstat -o all -234
command as shown below.
[root@localhost ~]# nfsstat -o all -234 Client packet stats: packets udp tcp tcpconn 0 0 0 0 Client rpc stats: calls retrans authrefrsh 57 0 57 Client nfs v2: null getattr setattr root lookup readlink 0 0% 0 0% 0 0% 0 0% 0 0% 0 0% read wrcache write create remove rename 0 0% 0 0% 0 0% 0 0% 0 0% 0 0% link symlink mkdir rmdir readdir fsstat 0 0% 0 0% 0 0% 0 0% 0 0% 0 0% Client nfs v3: null getattr setattr lookup access readlink 0 0% 0 0% 0 0% 0 0% 0 0% 0 0% read write create mkdir symlink mknod 0 0% 0 0% 0 0% 0 0% 0 0% 0 0% remove rmdir rename link readdir readdirplus 0 0% 0 0% 0 0% 0 0% 0 0% 0 0% fsstat fsinfo pathconf commit 0 0% 0 0% 0 0% 0 0% Client nfs v4: null read write commit open open_conf 0 0% 0 0% 0 0% 0 0% 0 0% 0 0% open_noat open_dgrd close setattr fsinfo renew 0 0% 0 0% 0 0% 0 0% 3 5% 0 0% setclntid confirm lock lockt locku access 0 0% 0 0% 0 0% 0 0% 0 0% 2 3% getattr lookup lookup_root remove rename link 2 3% 3 5% 1 1% 0 0% 0 0% 0 0% symlink create pathconf statfs readlink readdir 0 0% 0 0% 2 3% 0 0% 0 0% 0 0% server_caps delegreturn getacl setacl fs_locations rel_lkowner 5 8% 0 0% 0 0% 0 0% 0 0% 0 0% secinfo exchange_id create_ses destroy_ses sequence get_lease_t 0 0% 0 0% 1 1% 1 1% 0 0% 34 60% reclaim_comp layoutget getdevinfo layoutcommit layoutreturn getdevlist 0 0% 1 1% 0 0% 0 0% 0 0% 0 0% (null) 1 1%
-o : Show statistics on particular facilities. More on nfsstat command Man Page.
Example 8: How to Display NFS Stats in List Form
In the above examples you might be checking the nfsstat command output in little descriptive format. If you want to display the output in List format then you need to use nfsstat -l
command as shown below.
[root@localhost ~]# nfsstat -l nfs v4 client total: 85 ------------- ------------- -------- nfs v4 client fsinfo: 3 nfs v4 client access: 2 nfs v4 client getattr: 2 nfs v4 client lookup: 3 nfs v4 client lookup_root: 1 nfs v4 client pathconf: 2 nfs v4 client server_caps: 5 nfs v4 client create_ses: 1 nfs v4 client destroy_ses: 1 nfs v4 client get_lease_t: 63 nfs v4 client layoutget: 1 nfs v4 client (null): 1
-l : Prints stats in list format. More on nfsstat command Man Page.
Example 9: How to Check NFS Network Layer Statistics using nfsstat command
If you want to check NFS Network Layer Statistics only then you need to use -o net
with nfsstat command as shown below. From the below output you can check useful information like total number of packets, total number of TCP Connections etc. As of now there is no packet transfer happening between Server and Client so all the network stats value are showing 0.
[root@localhost ~]# nfsstat -o net Client packet stats: packets udp tcp tcpconn 0 0 0 0
Example 10: How to check all other options of nfsstat command in Linux
If you want to check all the options of nfsstat command then you need to use nfsstat --help
command as shown below.
[root@localhost ~]# nfsstat --help Usage: nfsstat [OPTION]... -m, --mounts Show statistics on mounted NFS filesystems -c, --client Show NFS client statistics -s, --server Show NFS server statistics -2 Show NFS version 2 statistics -3 Show NFS version 3 statistics -4 Show NFS version 4 statistics -o [facility] Show statistics on particular facilities. nfs NFS protocol information rpc General RPC information net Network layer statistics fh Usage information on the server's file handle cache rc Usage information on the server's request reply cache all Select all of the above -v, --verbose, --all Same as '-o all'
–help : What you just did. More on nfsstat command Man Page.
Popular Recommendations:-
How to Delete Elasticsearch Unassigned Shards in 4 Easy Steps
How to Delete Elasticsearch Red Status Indices in 3 Easy Steps
Understanding Kafka Console Producer and Consumer in 10 Easy Steps
Popular Apache Kafka Architecture Explained Using 4 Basic Components
17 Useful Apache Kafka Examples on Linux (RedHat/CentOS 7/8)
How to Install Apache Kafka on Ubuntu 18.04