nfsv3ops.d Counts NFSv3 Client Operations

This DTrace script counts NFS version 3 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");
}

nfsv3:::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 3 operations:

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

   Client                           Operation                       Count
   192.0.2.75                    op-commit-done                      1
   192.0.2.75                    op-commit-start                     1
   192.0.2.75                    op-create-done                      1
   192.0.2.75                    op-create-start                     1
   192.0.2.75                    op-access-done                      6
   192.0.2.75                    op-access-start                     6
   192.0.2.75                    op-read-done                        6
   192.0.2.75                    op-read-start                       6
   192.0.2.75                    op-write-done                       7
   192.0.2.75                    op-write-start                      7
   192.0.2.75                    op-lookup-done                      8
   192.0.2.75                    op-lookup-start                     8
   192.0.2.75                    op-getattr-done                    10
   192.0.2.75                    op-getattr-start                   10
  
   Client                           Operation                       Count
   
   Client                           Operation                       Count
   192.0.2.75                    op-getattr-done                     1
   192.0.2.75                    op-getattr-start                    1

The following table list the fields that are printed by the nfsv3ops.d script.

Field Description

Client

Remote client IP address

Operation

NFS version 3 operation, described using the nfsv3 provider probename

Count

Operations during this interval