1N/A# topsysproc - display top syscalls by process name. 1N/A# Written using DTrace (Solaris 10 3/05). 1N/A# This program continually prints a report of the number of system calls 1N/A# by process name, and refreshes the display every 1 second or as specified 1N/A# at the command line. Similar data can be fetched with "prstat -m". 1N/A# $Id: topsysproc 19 2007-09-12 07:47:59Z brendan $ 1N/A# USAGE: topsysproc [interval] 1N/A# load avg load averages, see uptime(1) 1N/A# syscalls total number of syscalls in this interval 1N/A# PROCESS process name 1N/A# COUNT number of occurances in this interval 1N/A# NOTE: There may be several PIDs with the same process name. 1N/A# SEE ALSO: prstat(1M) 1N/A# INSPIRATION: top(1) by William LeFebvre 1N/A# COPYRIGHT: Copyright (c) 2005 Brendan Gregg. 1N/A# The contents of this file are subject to the terms of the 1N/A# Common Development and Distribution License, Version 1.0 only 1N/A# (the "License"). You may not use this file except in compliance 1N/A# See the License for the specific language governing permissions 1N/A# and limitations under the License. 1N/A# 13-Jun-2005 Brendan Gregg Created this. 1N/A# 20-Apr-2006 " " Last update. 1N/Aif [
"$1" =
"-h" -o
"$1" =
"--help" ];
then 1N/A USAGE: topsysproc [interval] 1N/A topsysproc # default, 1 second updates 1N/A topsysproc 5 # 5 second updates 1N/Aif [ "$1" -gt 0 ]; then 1N/A/usr/sbin/dtrace -n ' 1N/A #pragma D option quiet 1N/A #pragma D option destructive 1N/A inline int INTERVAL = '$interval'; 1N/A inline int SCREEN = 20; 1N/A printf("Tracing... Please wait.\n"); 1N/A /* record syscall event */ 1N/A @Name[execname] = count(); 1N/A /++secs >= INTERVAL/ 1N/A /* fetch load averages */ 1N/A this->load1a = `hp_avenrun[0] / 65536; 1N/A this->load5a = `hp_avenrun[1] / 65536; 1N/A this->load15a = `hp_avenrun[2] / 65536; 1N/A this->load1b = ((`hp_avenrun[0] % 65536) * 100) / 65536; 1N/A this->load5b = ((`hp_avenrun[1] % 65536) * 100) / 65536; 1N/A this->load15b = ((`hp_avenrun[2] % 65536) * 100) / 65536; 1N/A /* print load average */ 1N/A printf("%Y, load average: %d.%02d, %d.%02d, %d.%02d", 1N/A walltimestamp, this->load1a, this->load1b, this->load5a, 1N/A this->load5b, this->load15a, this->load15b); 1N/A /* print syscall count */ 1N/A printa(" syscalls: %@d\n",@Total); 1N/A trunc(@Name, SCREEN); 1N/A printf("\n %-25s %12s\n", "PROCESS", "COUNT"); 1N/A printa(" %-25s %@12d\n", @Name); 1N/A /* reset variables */