xref: /freebsd/share/dtrace/nfsattrstats (revision c1eb4109f3b1d90a9c1538179ea6a52a191899b2)
1a223d3edSRui Paulo#!/usr/sbin/dtrace -s
2a223d3edSRui Paulo/*
3a223d3edSRui Paulo * Copyright (c) 2012 Robert N. M. Watson
4a223d3edSRui Paulo * All rights reserved.
5a223d3edSRui Paulo *
6a223d3edSRui Paulo * This software was developed at the University of Cambridge Computer
7a223d3edSRui Paulo * Laboratory with support from a grant from Google, Inc.
8a223d3edSRui Paulo *
9a223d3edSRui Paulo * Redistribution and use in source and binary forms, with or without
10a223d3edSRui Paulo * modification, are permitted provided that the following conditions
11a223d3edSRui Paulo * are met:
12a223d3edSRui Paulo * 1. Redistributions of source code must retain the above copyright
13a223d3edSRui Paulo *    notice, this list of conditions and the following disclaimer.
14a223d3edSRui Paulo * 2. Redistributions in binary form must reproduce the above copyright
15a223d3edSRui Paulo *    notice, this list of conditions and the following disclaimer in the
16a223d3edSRui Paulo *    documentation and/or other materials provided with the distribution.
17a223d3edSRui Paulo *
18a223d3edSRui Paulo * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19a223d3edSRui Paulo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20a223d3edSRui Paulo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21a223d3edSRui Paulo * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22a223d3edSRui Paulo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23a223d3edSRui Paulo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24a223d3edSRui Paulo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25a223d3edSRui Paulo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26a223d3edSRui Paulo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27a223d3edSRui Paulo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28a223d3edSRui Paulo * SUCH DAMAGE.
29a223d3edSRui Paulo *
30a223d3edSRui Paulo * $FreeBSD$
31a223d3edSRui Paulo *
32a223d3edSRui Paulo * This script creates a trace of NFS RPCs, NFS attribute cache
33a223d3edSRui Paulo * activity, and NFS access cache activity, along with the system call
34a223d3edSRui Paulo * that instigated the activity. Notice that NFS events may happen
35a223d3edSRui Paulo * outside of the context of a system call, most likely due to the VM
36a223d3edSRui Paulo * system paging from NFS, in which case the system call name is
37a223d3edSRui Paulo * reported as "-"
38a223d3edSRui Paulo */
39ed43a220SGeorge V. Neville-Neil
40ed43a220SGeorge V. Neville-Neil#pragma D option quiet
41ed43a220SGeorge V. Neville-Neil
42ed43a220SGeorge V. Neville-Neildtrace:::BEGIN
43ed43a220SGeorge V. Neville-Neil{
44ed43a220SGeorge V. Neville-Neil	printf("probe\targ0\texecutable\tsyscall\n");
45ed43a220SGeorge V. Neville-Neil}
46ed43a220SGeorge V. Neville-Neil
47ed43a220SGeorge V. Neville-Neilsyscall:::entry
48ed43a220SGeorge V. Neville-Neil{
49ed43a220SGeorge V. Neville-Neil
50ed43a220SGeorge V. Neville-Neil        self->syscallname = probefunc;
51ed43a220SGeorge V. Neville-Neil}
52ed43a220SGeorge V. Neville-Neil
53ed43a220SGeorge V. Neville-Neilsyscall:::return
54ed43a220SGeorge V. Neville-Neil{
55ed43a220SGeorge V. Neville-Neil
56ed43a220SGeorge V. Neville-Neil        self->syscallname = "";
57ed43a220SGeorge V. Neville-Neil}
58ed43a220SGeorge V. Neville-Neil
59*c1eb4109SGeorge V. Neville-Neilnfscl:::
60ed43a220SGeorge V. Neville-Neil/self->syscallname != 0 && self->syscallname != ""/
61ed43a220SGeorge V. Neville-Neil{
62ed43a220SGeorge V. Neville-Neil
63ed43a220SGeorge V. Neville-Neil    printf("%s\t%s\t%s\t%s\n", probemod, stringof(arg0), execname,
64ed43a220SGeorge V. Neville-Neil	    self->syscallname);
65ed43a220SGeorge V. Neville-Neil}
66ed43a220SGeorge V. Neville-Neil
67*c1eb4109SGeorge V. Neville-Neilnfscl:::
68ed43a220SGeorge V. Neville-Neil/self->syscallname == 0 || self->syscallname == ""/
69ed43a220SGeorge V. Neville-Neil{
70ed43a220SGeorge V. Neville-Neil
71ed43a220SGeorge V. Neville-Neil    printf("%s\t%s\t%s\t%s\n", probemod, stringof(arg0), execname,
72ed43a220SGeorge V. Neville-Neil	    self->syscallname);
73ed43a220SGeorge V. Neville-Neil}
74