nfsattrstats revision 238535
12116Sjkh#!/bin/sh
22116Sjkh#
32116Sjkh# Copyright (c) 2012 Robert N. M. Watson
42116Sjkh# All rights reserved.
52116Sjkh#
62116Sjkh# This software was developed at the University of Cambridge Computer
72116Sjkh# Laboratory with support from a grant from Google, Inc.
82116Sjkh#
92116Sjkh# Redistribution and use in source and binary forms, with or without
102116Sjkh# modification, are permitted provided that the following conditions
118870Srgrimes# are met:
122116Sjkh# 1. Redistributions of source code must retain the above copyright
132116Sjkh#    notice, this list of conditions and the following disclaimer.
142116Sjkh# 2. Redistributions in binary form must reproduce the above copyright
152116Sjkh#    notice, this list of conditions and the following disclaimer in the
16176451Sdas#    documentation and/or other materials provided with the distribution.
17176451Sdas#
182116Sjkh# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
192116Sjkh# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
202116Sjkh# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
212116Sjkh# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
222116Sjkh# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
232116Sjkh# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2497413Salfred# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2597413Salfred# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
268870Srgrimes# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27226598Sdas# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
282116Sjkh# SUCH DAMAGE.
292116Sjkh#
302116Sjkh# $FreeBSD: head/share/dtrace/nfsattrstats 238535 2012-07-16 17:48:43Z gnn $
312116Sjkh#
322116Sjkh# This script creates a trace of NFS RPCs, NFS attribute cache
332116Sjkh# activity, and NFS access cache activity, along with the system call
348870Srgrimes# that instigated the activity. Notice that NFS events may happen
352116Sjkh# outside of the context of a system call, most likely due to the VM
362116Sjkh# system paging from NFS, in which case the system call name is
372116Sjkh# reported as "-"
38152353Sbde
39152353Sbde/usr/sbin/dtrace -n '
40152353Sbde#pragma D option quiet
412116Sjkh
422116Sjkhdtrace:::BEGIN
432116Sjkh{
442116Sjkh	printf("probe\targ0\texecutable\tsyscall\n");
452116Sjkh}
462116Sjkh
47152353Sbdesyscall:::entry
48152353Sbde{
492116Sjkh
50152353Sbde        self->syscallname = probefunc;
51226598Sdas}
52226598Sdas
532116Sjkhsyscall:::return
542116Sjkh{
552116Sjkh
562116Sjkh        self->syscallname = "";
57}
58
59nfsclient:::
60/self->syscallname != 0 && self->syscallname != ""/
61{
62
63    printf("%s\t%s\t%s\t%s\n", probemod, stringof(arg0), execname, 
64	    self->syscallname);
65}
66
67nfsclient:::
68/self->syscallname == 0 || self->syscallname == ""/
69{
70
71    printf("%s\t%s\t%s\t%s\n", probemod, stringof(arg0), execname, 
72	    self->syscallname);
73}
74'
75