3 # topsysproc - display top syscalls by process name.
4 # Written using DTrace (Solaris 10 3/05).
6 # This program continually prints a report of the number of system calls
7 # by process name, and refreshes the display every 1 second or as specified
8 # at the command line. Similar data can be fetched with "prstat -m".
10 # $Id: topsysproc 19 2007-09-12 07:47:59Z brendan $
12 # USAGE: topsysproc [interval]
15 # load avg load averages, see uptime(1)
16 # syscalls total number of syscalls in this interval
17 # PROCESS process name
18 # COUNT number of occurances in this interval
20 # NOTE: There may be several PIDs with the same process name.
22 # SEE ALSO: prstat(1M)
24 # INSPIRATION: top(1) by William LeFebvre
26 # COPYRIGHT: Copyright (c) 2005 Brendan Gregg.
30 # The contents of this file are subject to the terms of the
31 # Common Development and Distribution License, Version 1.0 only
32 # (the "License"). You may not use this file except in compliance
35 # You can obtain a copy of the license at Docs/cddl1.txt
36 # or http://www.opensolaris.org/os/licensing.
37 # See the License for the specific language governing permissions
38 # and limitations under the License.
42 # 13-Jun-2005 Brendan Gregg Created this.
43 # 20-Apr-2006 " " Last update.
49 if [ "$1" = "-h" -o "$1" = "--help" ]; then
51 USAGE: topsysproc [interval]
53 topsysproc # default, 1 second updates
54 topsysproc 5 # 5 second updates
59 if [ "$1" -gt 0 ]; then
67 #pragma D option quiet
68 #pragma D option destructive
71 inline int INTERVAL = '$interval';
72 inline int SCREEN = 20;
78 printf("Tracing... Please wait.\n");
81 /* record syscall event */
84 @Name[execname] = count();
92 /* fetch load averages */
93 this->load1a = `hp_avenrun[0] / 65536;
94 this->load5a = `hp_avenrun[1] / 65536;
95 this->load15a = `hp_avenrun[2] / 65536;
96 this->load1b = ((`hp_avenrun[0] % 65536) * 100) / 65536;
97 this->load5b = ((`hp_avenrun[1] % 65536) * 100) / 65536;
98 this->load15b = ((`hp_avenrun[2] % 65536) * 100) / 65536;
103 /* print load average */
104 printf("%Y, load average: %d.%02d, %d.%02d, %d.%02d",
105 walltimestamp, this->load1a, this->load1b, this->load5a,
106 this->load5b, this->load15a, this->load15b);
108 /* print syscall count */
109 printa(" syscalls: %@d\n",@Total);
112 trunc(@Name, SCREEN);
113 printf("\n %-25s %12s\n", "PROCESS", "COUNT");
114 printa(" %-25s %@12d\n", @Name);
116 /* reset variables */