/*
* vmstat.d - vmstat demo in DTrace.
* Written using DTrace (Solaris 10 3/05).
*
* This has been written to demonstrate fetching the same data as vmstat
* from DTrace. This program is intended as a starting point for other
* DTrace scripts, by beginning with familiar statistics.
*
* $Id: vmstat.d 8 2007-08-06 05:55:26Z brendan $
*
* USAGE: vmstat.d
*
* FIELDS:
* w swapped out LWPs number
* swap virtual memory free Kbytes
* free free RAM Kbytes
* re page reclaims Kbytes
* mf minor faults Kbytes
* pi page ins Kbytes
* po page outs Kbytes
* fr pages freed Kbytes
* sr scan rate pages
* in interrupts number
* sy system calls number
* cs context switches number
*
* NOTES:
* Most of the statistics are in units of kilobytes, unlike the
* original vmstat command which sometimes uses page counts.
* As this program does not use Kstat, there is no summary since boot line.
* Free RAM is both free free + cache free.
*
* SEE ALSO: vmstat(1M)
*
* COPYRIGHT: Copyright (c) 2005 Brendan Gregg.
*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the License for the specific language governing permissions
* and limitations under the License.
*
* CDDL HEADER END
*
* 11-Jun-2005 Brendan Gregg Created this.
* 08-Jan-2006 " " Last update.
*/
inline int SCREEN = 21;
/*
* Initialise variables
*/
{
}
/*
* Print header
*/
{
printf(" %1s %10s %8s %5s %5s %4s %4s %4s %4s %5s %6s %4s\n",
"w", "swap", "free", "re", "mf", "pi", "po", "fr", "sr",
"in", "sy", "cs");
lines = 0;
}
/*
* Probe events
*/
/*
* Print output line
*/
{
/* fetch free mem */
/*
* fetch free swap
*
* MAX(ani_max - ani_resv, 0) + (availrmem - swapfs_minfree)
*/
/* fetch w */
/* convert to Kbytes */
/* print line */
printf(" %1d %10d %8d %5d %5d %4d %4d %4d %4d %5d %6d %4d\n",
/* clear counters */
}