3 * sh_stat.d - Bourne shell operation stats using DTrace.
4 * Written for the sh DTrace provider.
6 * $Id: sh_stat.d 52 2007-09-24 04:28:01Z brendan $
8 * This traces activity from all sh processes on the system that are running
9 * with sh provider support.
11 * USAGE: sh_stat.d [interval [count]]
14 * EXEC/s Bourne shells executed per second, including
15 * those without sh provider support
16 * FUNC/s Functions called, per second
17 * BLTIN/s Builtins called, per second
18 * SUB-SH/s Sub-shells called, per second
19 * CMD/s External commands called, per second
21 * The numbers are counts for the interval specified. The default interval
24 * If you see a count in "EXECS" but not in the other columns, then sh
25 * scripts may be running without the DTrace sh provider. See Shell/Readme.
27 * Filename and function names are printed if available.
29 * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
33 * The contents of this file are subject to the terms of the
34 * Common Development and Distribution License, Version 1.0 only
35 * (the "License"). You may not use this file except in compliance
38 * You can obtain a copy of the license at Docs/cddl1.txt
39 * or http://www.opensolaris.org/os/licensing.
40 * See the License for the specific language governing permissions
41 * and limitations under the License.
45 * 09-Sep-2007 Brendan Gregg Created this.
48 #pragma D option quiet
49 #pragma D option defaultargs
51 inline int SCREEN = 21;
55 execs = funcs = builtins = subs = cmds = 0;
57 interval = $1 ? $1 : 1;
58 counts = $2 ? $2 : -1;
73 /first || (secs == 0 && lines > SCREEN)/
75 printf("%-20s %8s %8s %8s %8s %8s\n", "TIME", "EXEC/s", "FUNCS/s",
76 "BLTINS/s", "SUB-SH/s", "CMD/s");
117 printf("%-20Y %8d %8d %8d %8d %8d\n", walltimestamp, execs / interval,
118 funcs / interval, builtins / interval, subs / interval,
120 execs = funcs = builtins = subs = cmds = 0;