nfsv4ops.d Reports Client Operations

This DTrace script counts NFS version 4 operations by client, printing a summary every 5 seconds:

#!/usr/sbin/dtrace -s

#pragma D option quiet

dtrace:::BEGIN
{
        trace("Tracing... Interval 5 secs.\n");
}

nfsv4:::op-*
{
        @ops[args[0]->ci_remote, probename] = count();
}

profile:::tick-5sec,
dtrace:::END
{
        printf("\n   %-32s %-28s %8s\n", "Client", "Operation", "Count");
        printa("   %-32s %-28s %@8d\n", @ops);
        trunc(@ops);
}

The following output shows which client is sending which NFS version 4 operations:

# ./nfsv4ops.d 
Tracing... Interval 5 secs.

   Client                           Operation                       Count
   192.0.2.14                    op-getattr-done                     1
   192.0.2.14                    op-getattr-start                    1
   192.0.2.14                    op-putfh-done                       1
   192.0.2.14                    op-putfh-start                      1

   Client                           Operation                       Count
   192.0.2.14                    op-access-done                      1
   192.0.2.14                    op-access-start                     1
   192.0.2.14                    op-close-done                       1
   192.0.2.14                    op-close-start                      1
   192.0.2.14                    op-getfh-done                       1
   192.0.2.14                    op-getfh-start                      1
   192.0.2.14                    op-open-done                        1
   192.0.2.14                    op-open-start                       1
   192.0.2.14                    op-getattr-done                     3
   192.0.2.14                    op-getattr-start                    3
   192.0.2.14                    op-read-done                        9
   192.0.2.14                    op-read-start                       9
   192.0.2.14                    op-putfh-done                      12
   192.0.2.14                    op-putfh-start                     12
^C

   Client                           Operation                       Count

The fields printed are:

Field Description

Client

Remote client IP address

Operation

NFSv4 operation, described using the nfsv4 provider probename

Count

Operations during this interval