nfsmount
- lookup NFS filesystem root filehandles
nfsmount
[-AdDeEGhJlmqRTuv
] [-c
count] [-C
count] [-H
hertz] [-S
source] [-V
version] <server[:path]...>
nfsmount
sends MOUNT protocol version 3 RPC requests to NFS servers to look up exported filesystems and their root filehandles. Specific filesystems can be queried with an argument in the format hostname:path
. If the path is omitted then a separate EXPORT
RPC request is first sent to list all available filesystems which will then be looked up individually with MNT
RPC requests. In looping (-l
) and counting (-c
, -C
) modes, a single EXPORT request is sent before starting the main loop of MNT requests.
As recommended in RFC 2224, a UMNT RPC is sent after each successful MNT request to clean up client mount records on the server. This can be disabled with the -u
option.
While typically the MOUNT protocol is used to list the root filehandles for exported filesystems, it can also obtain filehandles for directories and files within an exported filesystem. (This behaviour can be disabled on some NFS servers, for example on Solaris with the nosub
option. On *BSD it must be enabled with the alldirs
option.)
The result(s) are returned as a series of JSON objects (one per line) with the keys "host", "ip", "path", "usec", "timestamp", "filehandle" and "version", where the value of the "filehandle" key is the hex representation of the filesystem's root NFS filehandle.
If the NFS server requires "secure" ports (<1024) for the mount daemon, nfsmount
must be run as root.
-A
Display IP addresses instead of hostnames. Also implied by -m
.
-c
countCount of (MNT) requests to send to each target's exported filesystems before exiting. For example, if a target has 4 filesystems exported, with a count 5, 20 requests will be sent (5 to each filesystem). Print a line of ping
-style output after each response is received. A summary of all responses is printed when the count is reached or the program is interrupted.
-C
countCount of mount (MNT) requests to send to each target's exported filesystems. Outputs an fping(8)
compatible parseable summary of the response times (in milliseconds) of all requests when the count is reached or the program is interrupted. Errors or lost responses are represented with -
.
-d
Perform reverse DNS lookups for target(s). This option overrides -A
(and the implied -A
from the -m
option).
-D
Print timestamp (Unix time) before each line of output when counting or looping.
-e
Display available filesystems and their export policies in a human readable format, like showmount -e
. This sends a single EXPORT
RPC per target server and does not look up filehandles.
-E
Display output in Etsy's StatsD format (nfsmount.$hostname.$path.mountv3:msec|ms).
-G
Print output in Graphite format (nfsmount.$hostname.$path.mountv3.usec usec timestamp).
-h
Display a help message and exit.
-H
hertzThe polling frequency in Hertz. This is the number of requests sent to each target per second in looping and counting modes. Default = 1.
-J
Force JSON output, even in counting and looping modes.
-l
Loop forever sending mount (MNT) requests. Exit loop with Ctrl-c. A summary of all responses is printed when the program is interrupted.
-m
Use multiple target IP addresses if found. This can be useful for clustered file servers. Implies -A
(shows IP addresses instead of hostnames) so output isn't ambiguous.
-q
Quiet. Only print a summary.
-R
Don't reconnect to target servers after each loop. The default behaviour is to disconnect and reconnect after all of the exported filesystems on each target are queried.
-S
sourceUse the specified source IP address for request packets.
-T
Use TCP to connect to server. Default = UDP.
-u
Don't send a UMNT RPC after each successful MNT response. By default these are sent so that the server cleans up its records of mounted clients for each filesystem.
-v
Display debug output on stderr
.
-V
versionUse MOUNT protocol version
. Default = 3, supports versions 1/2/3. MOUNT version 3 is used by NFS version 3, version 1 is used by NFS version 2. Version 2 can also be used with NFS version 2 but this is less common. Versions 1 and 2 will return 32 byte filehandles, version 3 returns variable length filehandles up to 64 bytes.
Query a server for all available exports:
sudo nfsmount dumpy
Query a server for a specific export:
sudo nfsmount dumpy:/export
Query a server for a specific file:
sudo nfsmount dumpy:/export/home/mnt
Produce ping
-style output:
sudo nfsmount dumpy -l
By default, nfsmount
outputs a list of NFS root filehandles exported on the target server(s) as JSON objects, one per line:
{"host":"localhost","ip":"127.0.0.1","path":"\/export","usec":206,"timestamp":1459804688,"filehandle":"0100010000000000","version":3}
Slashes (/
) in the "path" field are automatically escaped. The "version" field represents the version of the MOUNT protocol (specified with the -V
option). Version 3 is used with NFS version 3, versions 1 and 2 are used with NFS version 2. "usec" is the number of microseconds that the RPC call took. "timestamp" is the Epoch time that the call was made.
When the -G
option is specified, nfsmount
will produce Graphite-compatible output:
nfsmount.localhost./.mountv3.usec 256 1459805225
When the -E
option is specified, nfsmount
will produce StatsD-compatible output:
nfsmount.localhost./.mountv3:0.20|ms
nfsmount
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