3 * sar-c.d - sar -c demo in DTrace.
4 * Written using DTrace (Solaris 10 3/05).
6 * This has been written to demonstrate fetching similar data as sar -c
7 * from DTrace. This program is intended as a starting point for other
8 * DTrace scripts, by beginning with familiar statistics.
10 * $Id: sar-c.d 3 2007-08-01 10:50:08Z brendan $
15 * scall/s System calls
20 * rchar/s read characters
21 * wchar/s write characters
23 * IDEA: David Rubio, who also wrote the original.
26 * As this program does not use Kstat, there is no summary since boot line.
30 * COPYRIGHT: Copyright (c) 2005 Brendan Gregg.
34 * The contents of this file are subject to the terms of the
35 * Common Development and Distribution License, Version 1.0 only
36 * (the "License"). You may not use this file except in compliance
39 * You can obtain a copy of the license at Docs/cddl1.txt
40 * or http://www.opensolaris.org/os/licensing.
41 * See the License for the specific language governing permissions
42 * and limitations under the License.
46 * 12-Jun-2005 Brendan Gregg Created this.
47 * 12-Jun-2005 " " Last update.
50 #pragma D option quiet
52 inline int SCREEN = 21;
55 * Initialise variables
59 scall = 0; sread = 0; swrit = 0; fork = 0; exec = 0;
71 printf("%-20s %7s %7s %7s %7s %7s %8s %8s\n",
72 "Time", "scall/s", "sread/s", "swrit/s", "fork/s",
73 "exec/s", "rchar/s", "wchar/s");
80 syscall:::entry { scall++; }
81 sysinfo:::sysread { sread++; }
82 sysinfo:::syswrite { swrit++; }
83 sysinfo:::sysfork { fork++; }
84 sysinfo:::sysvfork { fork++; }
85 sysinfo:::sysexec { exec++; }
86 sysinfo:::readch { rchar += arg0; }
87 sysinfo:::writech { wchar += arg0; }
95 printf("%20Y %7d %7d %7d %4d.00 %4d.00 %8d %8d\n",
96 walltimestamp, scall, sread, swrit, fork, exec, rchar, wchar);
99 scall = 0; sread = 0; swrit = 0; fork = 0; exec = 0;
100 rchar = 0; wchar = 0;