1238535Sgnn#!/bin/sh
2238535Sgnn#
3238535Sgnn# Copyright (c) 2012 Robert N. M. Watson
4238535Sgnn# All rights reserved.
5238535Sgnn#
6238535Sgnn# This software was developed at the University of Cambridge Computer
7238535Sgnn# Laboratory with support from a grant from Google, Inc.
8238535Sgnn#
9238535Sgnn# Redistribution and use in source and binary forms, with or without
10238535Sgnn# modification, are permitted provided that the following conditions
11238535Sgnn# are met:
12238535Sgnn# 1. Redistributions of source code must retain the above copyright
13238535Sgnn#    notice, this list of conditions and the following disclaimer.
14238535Sgnn# 2. Redistributions in binary form must reproduce the above copyright
15238535Sgnn#    notice, this list of conditions and the following disclaimer in the
16238535Sgnn#    documentation and/or other materials provided with the distribution.
17238535Sgnn#
18238535Sgnn# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19238535Sgnn# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20238535Sgnn# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21238535Sgnn# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22238535Sgnn# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23238535Sgnn# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24238535Sgnn# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25238535Sgnn# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26238535Sgnn# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27238535Sgnn# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28238535Sgnn# SUCH DAMAGE.
29238535Sgnn#
30238535Sgnn# $FreeBSD$
31238535Sgnn#
32238535Sgnn# This script creates a trace of NFS RPCs, NFS attribute cache
33238535Sgnn# activity, and NFS access cache activity, along with the system call
34238535Sgnn# that instigated the activity. Notice that NFS events may happen
35238535Sgnn# outside of the context of a system call, most likely due to the VM
36238535Sgnn# system paging from NFS, in which case the system call name is
37238535Sgnn# reported as "-"
38238535Sgnn
39238535Sgnn/usr/sbin/dtrace -n '
40238535Sgnn#pragma D option quiet
41238535Sgnn
42238535Sgnndtrace:::BEGIN
43238535Sgnn{
44238535Sgnn	printf("probe\targ0\texecutable\tsyscall\n");
45238535Sgnn}
46238535Sgnn
47238535Sgnnsyscall:::entry
48238535Sgnn{
49238535Sgnn
50238535Sgnn        self->syscallname = probefunc;
51238535Sgnn}
52238535Sgnn
53238535Sgnnsyscall:::return
54238535Sgnn{
55238535Sgnn
56238535Sgnn        self->syscallname = "";
57238535Sgnn}
58238535Sgnn
59238535Sgnnnfsclient:::
60238535Sgnn/self->syscallname != 0 && self->syscallname != ""/
61238535Sgnn{
62238535Sgnn
63238535Sgnn    printf("%s\t%s\t%s\t%s\n", probemod, stringof(arg0), execname, 
64238535Sgnn	    self->syscallname);
65238535Sgnn}
66238535Sgnn
67238535Sgnnnfsclient:::
68238535Sgnn/self->syscallname == 0 || self->syscallname == ""/
69238535Sgnn{
70238535Sgnn
71238535Sgnn    printf("%s\t%s\t%s\t%s\n", probemod, stringof(arg0), execname, 
72238535Sgnn	    self->syscallname);
73238535Sgnn}
74238535Sgnn'
75