2

I'm currently using https://github.com/siebenmann/cks-dtrace/blob/master/nfs3-mon.d to identify most active datasets on our NFS server (Solaris 10)

Unfortunately I need to dig deeper, and I would like to be able to track down most used files. Is there a way to list top X files for various operations?

I'm not dtrace guru and was not able to find answer in few hours..

Andrew Henle
  • 1,232
  • 9
  • 11
Samoo
  • 21
  • 1

1 Answers1

1

The docs for the NFS DTrace provider are pretty good on the Oracle website. The scripts in particular that look useful to you are nfsv3fileio.d or (to get a lot more data that you might have to post-process) nfsv3rwsnoop.d.

Assuming you mean "most used" as in "highest number of reads / writes", and you don't care about the proportion between those or who is doing them, a simple script to print the filenames and the IO count to each of them is:

nfsv3:::op-read-start, nfsv3:::op-write-start {
     @[args[1]->noi_curpath] = count();
}

tick-10sec {
    printa(@);
    trunc(@);
}

(I didn't run this because I don't have any NFS shares set up, but I think it will work.) To summarize what it's doing:

  1. nfsv3:::op-{read|write}-start are the events that trigger when a read or a write begins on an NFSv3 share. Each time one of those happens, the event gets an argument args[1] that contains the variable noi_curpath, which gives the file's path (if available; occasionally it's not cached so you get nothing). We use that as a key, and use the count() of times this happens as the value in a map named @.
  2. tick-10sec is an event that triggers every 10 seconds, starting 10 seconds after the script begins. It first prints the map with printa(), and then clears the values in it with trunc() so we get fresh data for the next 10 second window.
Dan
  • 270
  • 2
  • 8
  • Note that the document you linked is Solaris 11. OP is running Solaris 10, so the Solaris 11 scripts may not work, especially for NFSv4. – Andrew Henle Nov 29 '18 at 10:46