1. nfsdf(8)
  2. nfsdf(8)

NAME

nfsdf - report NFS server disk space usage

SYNOPSIS

nfsdf [-AbgGhiklmMntTv] [-c count] [-H hertz] [-p prefix] [-S source]

DESCRIPTION

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.

OPTIONS

-A

Display IP addresses (instead of hostnames).

-b

Report disk space in bytes.

-c count

Count of FSSTAT requests to send to each input filehandle before exiting.

-g

Report 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.

-G

Graphite format output. Default is human readable (-h).

-h

Report disk space in human readable format (default). This selects whichever unit is the most compact to display in 4 digits of precision.

-H hertz

The 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.

-i

Report 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.

-k

Report 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.

-l

Loop forever. Exit loop with Ctrl-c.

-m

Report 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.

-M

Query 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.

-n

Only print the header once. Otherwise, the header is repeated once per screen of output. No header is printed in Graphite (-G) mode.

-p prefix

Specify string prefix for Graphite metric names. Default = "nfs".

-S source

Use the specified source IP address for request packets.

-t

Report 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.

-T

Use TCP to connect to servers. Default = UDP.

-v

Display debug output on stderr.

EXAMPLES

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

RETURN VALUES

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).

AUTHOR

Matt Provost, mprovost@termcap.net

Copyright 2017 Matt Provost
RPC files Copyright Sun Microsystems
NFSv4 files Copyright IETF

  1. January 2017
  2. nfsdf(8)