nfsdf - report NFS server disk space usage
nfsdf [-AbgGhiklmMntTv] [-c count] [-H hertz] [-p prefix] [-S source]
nfsdf accepts NFS filehandles on stdin and sends NFS version 3 FSSTAT RPC requests to each NFS server and reports the total, used and available amounts of disk space and files (inodes) for the filesystems specified, as well as the response time for each RPC request in milliseconds. nfsdf waits until the end of input (EOF) before sending any requests so that the correct width header can be printed. The default output is human readable, similar to df -h, units can be specified with the -b, -k, -m, -g, or -t options. Any filehandle on the target filesystem can be used as an argument, including the root filehandle obtained from nfsmount.
Input filehandles are represented as a series of JSON objects (one per line) with the keys "host", "ip", "path", and "filehandle", where the value of the "filehandle" key is the hex representation of the file's NFS filehandle.
If the NFS server requires "secure" ports (<1024), nfsdf will have to be run as root.
-ADisplay IP addresses (instead of hostnames).
-bReport disk space in bytes.
-c countCount of FSSTAT requests to send to each input filehandle before exiting.
-gReport disk space in gigabytes. Results that have a nonzero size but that are less than 1GB are shown as >0 to distinguish them from zero length results.
-GGraphite format output. Default is human readable (-h).
-hReport disk space in human readable format (default). This selects whichever unit is the most compact to display in 4 digits of precision.
-H hertzThe polling frequency in Hertz when in looping (-l) or counting (-c) mode. This is the number of requests sent to each target filesystem per second. Default = 1.
-iReport inodes (files) instead of disk space. Displays the total number of inodes on the filesystem, the amounts used and free, the capacity as a percentage and the time in milliseconds that each FSSTAT RPC call took.
-kReport disk space in kilobytes. Results that have a nonzero size but that are less than 1KB are shown as >0 to distinguish them from zero length results.
-lLoop forever. Exit loop with Ctrl-c.
-mReport disk space in megabytes. Results that have a nonzero size but that are less than 1MB are shown as >0 to distinguish them from zero length results.
-MQuery the RPC portmapper on the server to lookup the NFS port. Otherwise connect directly to the standard port (2049). Uses UDP by default or TCP if the -T option is specified.
-nOnly print the header once. Otherwise, the header is repeated once per screen of output. No header is printed in Graphite (-G) mode.
-p prefixSpecify string prefix for Graphite metric names. Default = "nfs".
-S sourceUse the specified source IP address for request packets.
-tReport disk space in terabytes. Results that have a nonzero size but that are less than 1TB are shown as >0 to distinguish them from zero length results.
-TUse TCP to connect to servers. Default = UDP.
-vDisplay debug output on stderr.
Typically nfsdf will use a filehandle obtained from the output of the nfsmount command:
sudo sh -c "nfsmount dumpy | nfsdf"
Since both commands typically need root privileges (to bind to a "secure" port) they can be run with a single subshell under sudo.
If the check is being run repeatedly, there is no need to query the fileserver with nfsmount every time. Since the root filehandles shouldn't change, the output can be stored in a file:
sudo nfsmount dumpy > dumpy.nfs
sudo nfsdf < dumpy.nfs
nfsdf will return 0 if all requests to all targets received successful responses. Nonzero exit codes indicate a failure. 1 is an RPC error, 2 is a name resolution failure, 3 is an initialisation failure (typically bad arguments).
Matt Provost, mprovost@termcap.net
Copyright 2017 Matt Provost
RPC files Copyright Sun Microsystems
NFSv4 files Copyright IETF