1235614Sgnn#!/bin/sh 2235614Sgnn# 3235614Sgnn# Copyright (c) 2012 Robert N. M. Watson 4235614Sgnn# All rights reserved. 5235614Sgnn# 6235614Sgnn# This software was developed at the University of Cambridge Computer 7235614Sgnn# Laboratory with support from a grant from Google, Inc. 8235614Sgnn# 9235614Sgnn# Redistribution and use in source and binary forms, with or without 10235614Sgnn# modification, are permitted provided that the following conditions 11235614Sgnn# are met: 12235614Sgnn# 1. Redistributions of source code must retain the above copyright 13235614Sgnn# notice, this list of conditions and the following disclaimer. 14235614Sgnn# 2. Redistributions in binary form must reproduce the above copyright 15235614Sgnn# notice, this list of conditions and the following disclaimer in the 16235614Sgnn# documentation and/or other materials provided with the distribution. 17235614Sgnn# 18235614Sgnn# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19235614Sgnn# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20235614Sgnn# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21235614Sgnn# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22235614Sgnn# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23235614Sgnn# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24235614Sgnn# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25235614Sgnn# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26235614Sgnn# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27235614Sgnn# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28235614Sgnn# SUCH DAMAGE. 29235614Sgnn# 30235614Sgnn# $FreeBSD: releng/10.2/share/dtrace/nfsclienttime 235614 2012-05-18 16:47:15Z gnn $ 31235614Sgnn# 32235614Sgnn# This script measures all time spent waiting on RPC replies for each 33235614Sgnn# system call, and then generates a histogram of those times sorted by 34235614Sgnn# system call name. 35235614Sgnn# 36235614Sgnn# Currently only supports NFSv3 37235614Sgnn# 38235614Sgnn# Usage: nfsclienttime 39235614Sgnn# 40235614Sgnn# Press Ctrl-C to exit and display statistics. 41235614Sgnn# 42235614Sgnn 43235614Sgnn/usr/sbin/dtrace -n ' 44235614Sgnn#pragma D option quiet 45235614Sgnn 46235614Sgnndtrace:::BEGIN 47235614Sgnn{ 48235614Sgnn printf("Collecting data...press Ctrl-C to exit.\n"); 49235614Sgnn} 50235614Sgnn 51235614Sgnnsyscall:::entry 52235614Sgnn{ 53235614Sgnn 54235614Sgnn self->count = 0; 55235614Sgnn} 56235614Sgnn 57235614Sgnnnfsclient:nfs3::start 58235614Sgnn{ 59235614Sgnn 60235614Sgnn self->timestamp = timestamp; 61235614Sgnn} 62235614Sgnn 63235614Sgnnnfsclient:nfs3::done 64235614Sgnn{ 65235614Sgnn 66235614Sgnn self->count += (timestamp - self->timestamp); 67235614Sgnn} 68235614Sgnn 69235614Sgnnsyscall:::return 70235614Sgnn/self->count != 0/ { 71235614Sgnn 72235614Sgnn @syscalls[probefunc] = quantize(self->count); 73235614Sgnn} 74235614Sgnn' 75