1N/A# Written using DTrace (Solaris 10 3/05). 1N/A# This program provides vmstat like data for one particular PID, a 1N/A# process name, or when running a command. It prints statistics 1N/A# $Id: dvmstat 3 2007-08-01 10:50:08Z brendan $ 1N/A# USAGE: dvmstat { -p PID | -n name | command } 1N/A# dvmstat -p 1871 # examine PID 1871 1N/A# dvmstat -n tar # examine processes called "tar" 1N/A# dvmstat df -h # run and examine "df -h" 1N/A# re page reclaims Kbytes 1N/A# maj major faults Kbytes 1N/A# mf minor faults Kbytes 1N/A# fr page frees Kbytes 1N/A# epi executable page ins Kbytes 1N/A# epo executable page out Kbytes 1N/A# api anonymous page ins Kbytes 1N/A# apo anonymous page outs Kbytes 1N/A# fpi filesystem page ins Kbytes 1N/A# fpo filesystem page outs Kbytes 1N/A# sy system calls number 1N/A# SEE ALSO: vmstat(1M) 1N/A# When using dvmstat to run a command - if the command takes some time 1N/A# to execute, dvmstat will print output every second. If the command runs 1N/A# in less than a second, then the only one line of output will be printed. 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# Author: Brendan Gregg [Sydney, Australia] 1N/A# 12-Jun-2005 Brendan Gregg Created this. 1N/A# 08-Jan-2006 " " Last update. ############################## # --- Process Arguments --- USAGE: dvmstat [-h] { -p PID | -n name | command } -p PID # examine this PID -n name # examine this process name dvmstat -p 1871 # examine PID 1871 dvmstat -n tar # examine processes called "tar" dvmstat df -h # run and examine "df -h" if [ $opt_pid -eq 0 -a $opt_name -eq 0 ]; then ################################# # --- Main Program, DTrace --- inline int OPT_pid = '$opt_pid'; inline int OPT_name = '$opt_name'; inline int OPT_command = '$opt_command'; inline string NAME = "'$pname'"; inline string COMMAND = "'$command'"; epi = 0; epo = 0; api = 0; apo = 0; fpi = 0; fpo = 0; re = 0; mf = 0; maj = 0; fr = 0; sy = 0; /(OPT_command && probename == "END") || (!(OPT_command && probename == "BEGIN") && lines++ > SCREEN)/ printf("%6s %5s %5s %4s %4s %4s %4s %4s %4s %4s %6s\n", "re", "maj", "mf", "fr", "epi", "epo", "api", "apo", * this intentionally does not use an associative array for storing data, * for reasons of performance. /(OPT_pid && pid == PID) || (OPT_name && execname == NAME) || (OPT_command && pid == $target)/ /(OPT_pid && pid == PID) || (OPT_name && execname == NAME) || (OPT_command && pid == $target)/ /(OPT_pid && pid == PID) || (OPT_name && execname == NAME) || (OPT_command && pid == $target)/ /(OPT_pid && pid == PID) || (OPT_name && execname == NAME) || (OPT_command && pid == $target)/ /(OPT_pid && pid == PID) || (OPT_name && execname == NAME) || (OPT_command && pid == $target)/ /(OPT_pid && pid == PID) || (OPT_name && execname == NAME) || (OPT_command && pid == $target)/ /(OPT_pid && pid == PID) || (OPT_name && execname == NAME) || (OPT_command && pid == $target)/ /(OPT_pid && pid == PID) || (OPT_name && execname == NAME) || (OPT_command && pid == $target)/ /(OPT_pid && pid == PID) || (OPT_name && execname == NAME) || (OPT_command && pid == $target)/ /(OPT_pid && pid == PID) || (OPT_name && execname == NAME) || (OPT_command && pid == $target)/ /(OPT_pid && pid == PID) || (OPT_name && execname == NAME) || (OPT_command && pid == $target)/ maj *= `_pagesize / 1024; epi *= `_pagesize / 1024; epo *= `_pagesize / 1024; api *= `_pagesize / 1024; apo *= `_pagesize / 1024; fpi *= `_pagesize / 1024; fpo *= `_pagesize / 1024; printf("%6d %5d %5d %4d %4d %4d %4d %4d %4d %4d %6d\n", re, maj, mf, fr, epi, epo, api, apo, fpi, fpo, sy); epi = 0; epo = 0; api = 0; apo = 0; fpi = 0; fpo = 0; re = 0; mf = 0; maj = 0; fr = 0; sy = 0; if [ $opt_command -eq 1 ]; then /usr/sbin/dtrace -n "$dtrace" -x evaltime=exec -c "$command" >&2 /usr/sbin/dtrace -n "$dtrace" >&2