Here is a dtrace script based of one of the examples for the nfs provider.
Especially useful when you use NFS for ESX or other hypervisors.

Andreas

#!/usr/sbin/dtrace -s

#pragma D option quiet

inline int TOP_FILES = 50;

dtrace:::BEGIN
{
   printf("Tracing... Hit Ctrl-C to end.\n");
   startscript = timestamp;
}

nfsv3:::op-read-start,
nfsv3:::op-write-start
{
   start[args[1]->noi_xid] = timestamp;
   size[args[1]->noi_xid] = args[2]->count;
}

nfsv3:::op-read-done,
nfsv3:::op-write-done
/start[args[1]->noi_xid] != 0/
{
      this->elapsed = timestamp - start[args[1]->noi_xid];
      this->size = size[args[1]->noi_xid];
      @rw[probename == "op-read-done" ? "read" : "write"] = 
quantize(this->elapsed / 1000);
      @host[args[0]->ci_remote] = sum(this->elapsed);
      @file[args[1]->noi_curpath] = sum(this->elapsed);
      @rwsc[probename == "op-read-done" ? "read" : "write"] = count();
      @rws[probename == "op-read-done" ? "read" : "write"] = 
quantize(this->size);
/*       @rwsl[probename == "op-read-done" ? "read" : "write"] = 
lquantize(this->size,4096,8256,64);
 */      @hosts[args[0]->ci_remote] = sum(this->size);
      @files[args[1]->noi_curpath] = sum(this->size);
      this->size = 0;
      size[args[1]->noi_xid] = 0;
      start[args[1]->noi_xid] = 0;
}

dtrace:::END
{
   this->seconds = (timestamp - startscript)/1000000000;
   printf("\nNFSv3 read/write top %d files (total us):\n", TOP_FILES);
   normalize(@file, 1000);
   trunc(@file, TOP_FILES);
   printa(@file);

   printf("NFSv3 read/write distributions (us):\n");
   printa(@rw);

   printf("\nNFSv3 read/write top %d files (total MByte):\n", TOP_FILES);
   normalize(@files, 1024*1024);
   trunc(@files, TOP_FILES);
   printa(@files);

   printf("\nNFSv3 read/write by host (total ns):\n");
   printa(@host);

   printf("\nNFSv3 read/write by host (total s):\n");
   normalize(@host, 1000000000);
   printa(@host);

   printf("\nNFSv3 read/write by host (total Byte):\n");
   printa(@hosts);

   printf("\nNFSv3 read/write by host (total kByte):\n");
   normalize(@hosts,1024);
   printa(@hosts);
   denormalize(@hosts);

   printf("\nNFSv3 read/write by host (total kByte/s):\n");
   normalize(@hosts,this->seconds*1024);
   printa(@hosts);

   printf("NFSv3 read/write distributions (Byte):\n");
   printa(@rws);

/*    printf("NFSv3 read/write distributions (Byte):\n");
   printa(@rwsl);
 */
   printf("NFSv3 read/write counts:\n");
   printa(@rwsc);

   printf("\nScript running for %20d seconds ",this->seconds);
}
-- 
This message posted from opensolaris.org
_______________________________________________
zfs-discuss mailing list
zfs-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/zfs-discuss

Reply via email to