3421N/A# Written using DTrace (Solaris 10 3/05). 3421N/A# This program provides vmstat like data for one particular PID, a 3421N/A# process name, or when running a command. It prints statistics 3421N/A# $Id: dvmstat 3 2007-08-01 10:50:08Z brendan $ 3421N/A# USAGE: dvmstat { -p PID | -n name | command } 3421N/A# dvmstat -p 1871 # examine PID 1871 3421N/A# dvmstat -n tar # examine processes called "tar" 3421N/A# dvmstat df -h # run and examine "df -h" 3421N/A# epi executable page ins Kbytes 3421N/A# epo executable page out Kbytes 3421N/A# api anonymous page ins Kbytes 3421N/A# apo anonymous page outs Kbytes 3421N/A# fpi filesystem page ins Kbytes 3421N/A# fpo filesystem page outs Kbytes 3421N/A# When using dvmstat to run a command - if the command takes some time 3421N/A# to execute, dvmstat will print output every second. If the command runs 3421N/A# in less than a second, then the only one line of output will be printed. 3421N/A# COPYRIGHT: Copyright (c) 2005 Brendan Gregg. 3421N/A# The contents of this file are subject to the terms of the 3421N/A# Common Development and Distribution License, Version 1.0 only 3421N/A# (the "License"). You may not use this file except in compliance 3421N/A# See the License for the specific language governing permissions 3421N/A# and limitations under the License. 3421N/A# Author: Brendan Gregg [Sydney, Australia] 3421N/A# 12-Jun-2005 Brendan Gregg Created this. 3421N/A# 08-Jan-2006 " " Last update. 3421N/A############################## 3421N/A USAGE: dvmstat [-h] { -p PID | -n name | command } 3421N/A -n name # examine this process name 3421N/A dvmstat -p 1871 # examine PID 1871 3421N/A dvmstat -n tar # examine processes called "tar" 3421N/A dvmstat df -h # run and examine "df -h" 3421N/Aif [ $opt_pid -eq 0 -a $opt_name -eq 0 ]; then 3421N/A################################# 3421N/A# --- Main Program, DTrace --- 3421N/A inline int OPT_pid = '$opt_pid'; 3421N/A inline int OPT_name = '$opt_name'; 3421N/A inline int OPT_command = '$opt_command'; 3421N/A inline string NAME = "'$pname'"; 3421N/A inline string COMMAND = "'$command'"; 3421N/A epi = 0; epo = 0; api = 0; apo = 0; fpi = 0; fpo = 0; 3421N/A re = 0; mf = 0; maj = 0; fr = 0; sy = 0; 3421N/A /(OPT_command && probename == "END") || 3421N/A (!(OPT_command && probename == "BEGIN") && lines++ > SCREEN)/ 3421N/A printf("%6s %5s %5s %4s %4s %4s %4s %4s %4s %4s %6s\n", 3421N/A "re", "maj", "mf", "fr", "epi", "epo", "api", "apo", 3421N/A * this intentionally does not use an associative array for storing data, 3421N/A * for reasons of performance. 3421N/A /(OPT_pid && pid == PID) || 3421N/A (OPT_name && execname == NAME) || 3421N/A (OPT_command && pid == $target)/ 3421N/A /(OPT_pid && pid == PID) || 3421N/A (OPT_name && execname == NAME) || 3421N/A (OPT_command && pid == $target)/ 3421N/A /(OPT_pid && pid == PID) || 3421N/A (OPT_name && execname == NAME) || 3421N/A (OPT_command && pid == $target)/ 3421N/A /(OPT_pid && pid == PID) || 3421N/A (OPT_name && execname == NAME) || 3421N/A (OPT_command && pid == $target)/ 3421N/A /(OPT_pid && pid == PID) || 3421N/A (OPT_name && execname == NAME) || 3421N/A (OPT_command && pid == $target)/ 3421N/A /(OPT_pid && pid == PID) || 3421N/A (OPT_name && execname == NAME) || 3421N/A (OPT_command && pid == $target)/ 3421N/A /(OPT_pid && pid == PID) || 3421N/A (OPT_name && execname == NAME) || 3421N/A (OPT_command && pid == $target)/ 3421N/A /(OPT_pid && pid == PID) || 3421N/A (OPT_name && execname == NAME) || 3421N/A (OPT_command && pid == $target)/ 3421N/A /(OPT_pid && pid == PID) || 3421N/A (OPT_name && execname == NAME) || 3421N/A (OPT_command && pid == $target)/ 3421N/A /(OPT_pid && pid == PID) || 3421N/A (OPT_name && execname == NAME) || 3421N/A (OPT_command && pid == $target)/ 3421N/A /(OPT_pid && pid == PID) || 3421N/A (OPT_name && execname == NAME) || 3421N/A (OPT_command && pid == $target)/ 3421N/A printf("%6d %5d %5d %4d %4d %4d %4d %4d %4d %4d %6d\n", 3421N/A re, maj, mf, fr, epi, epo, api, apo, fpi, fpo, sy); 3421N/A epi = 0; epo = 0; api = 0; apo = 0; fpi = 0; fpo = 0; 3421N/A re = 0; mf = 0; maj = 0; fr = 0; sy = 0; 3421N/Aif [ $opt_command -eq 1 ]; then 3421N/A /usr/sbin/dtrace -n "$dtrace" -x evaltime=exec -c "$command" >&2 3421N/A /usr/sbin/dtrace -n "$dtrace" >&2