Home | History | Annotate | Line # | Download | only in Mem
      1  1.1  christos #!/usr/sbin/dtrace -Cs
      2  1.1  christos /*
      3  1.1  christos  * anonpgpid.d - anonymous memory paging info by process on CPU.
      4  1.1  christos  *               Written using DTrace (Solaris 10 3/05).
      5  1.1  christos  *
      6  1.1  christos  * This scripts may help identify which processes are affected by a system
      7  1.1  christos  * with low memory, which is paging to the physical swap device. A report
      8  1.1  christos  * of the process on the CPU when paging occured is printed.
      9  1.1  christos  *
     10  1.1  christos  * $Id: anonpgpid.d,v 1.1.1.1 2015/09/30 22:01:09 christos Exp $
     11  1.1  christos  *
     12  1.1  christos  * USAGE:	anonpgpid.d 	# hit Ctrl-C to end
     13  1.1  christos  *
     14  1.1  christos  * FIELDS:
     15  1.1  christos  *		PID		Process ID
     16  1.1  christos  *		CMD		Process name
     17  1.1  christos  *		D		Direction, Read or Write
     18  1.1  christos  *		BYTES		Total bytes during sample
     19  1.1  christos  *
     20  1.1  christos  * NOTES:
     21  1.1  christos  *
     22  1.1  christos  * This program is currently an approximation - often the process when writing
     23  1.1  christos  * pages to swap will be "pageout" the pageout scanner, or "rcapd" the
     24  1.1  christos  * resource capping daemon.
     25  1.1  christos  *
     26  1.1  christos  * THANKS: James Dickens
     27  1.1  christos  *
     28  1.1  christos  * COPYRIGHT: Copyright (c) 2006 Brendan Gregg.
     29  1.1  christos  *
     30  1.1  christos  * CDDL HEADER START
     31  1.1  christos  *
     32  1.1  christos  *  The contents of this file are subject to the terms of the
     33  1.1  christos  *  Common Development and Distribution License, Version 1.0 only
     34  1.1  christos  *  (the "License").  You may not use this file except in compliance
     35  1.1  christos  *  with the License.
     36  1.1  christos  *
     37  1.1  christos  *  You can obtain a copy of the license at Docs/cddl1.txt
     38  1.1  christos  *  or http://www.opensolaris.org/os/licensing.
     39  1.1  christos  *  See the License for the specific language governing permissions
     40  1.1  christos  *  and limitations under the License.
     41  1.1  christos  *
     42  1.1  christos  * CDDL HEADER END
     43  1.1  christos  *
     44  1.1  christos  * TODO:
     45  1.1  christos  *
     46  1.1  christos  * Track processes accurately. This is a little difficult - anonpgout
     47  1.1  christos  * occurs asynchronously to the process, and events related to this don't
     48  1.1  christos  * point back to the process.
     49  1.1  christos  *
     50  1.1  christos  * Author: Brendan Gregg  [Sydney, Australia]
     51  1.1  christos  *
     52  1.1  christos  * 25-Jul-2005	Brendan Gregg	Created this.
     53  1.1  christos  * 18-Feb-2006	   "      "	Last update.
     54  1.1  christos  */
     55  1.1  christos 
     56  1.1  christos #include <sys/vnode.h>
     57  1.1  christos 
     58  1.1  christos #pragma D option quiet
     59  1.1  christos 
     60  1.1  christos dtrace:::BEGIN
     61  1.1  christos {
     62  1.1  christos 	printf("Tracing... Hit Ctrl-C to end.\n");
     63  1.1  christos }
     64  1.1  christos 
     65  1.1  christos fbt::pageio_setup:entry
     66  1.1  christos /((args[2]->v_flag & (VISSWAP | VSWAPLIKE)) != 0)/
     67  1.1  christos {
     68  1.1  christos 	@total[pid, execname, args[3] & B_READ ? "R" : "W"] = sum(arg1);
     69  1.1  christos }
     70  1.1  christos 
     71  1.1  christos dtrace:::END
     72  1.1  christos {
     73  1.1  christos 	printf("%6s %-16s %1s %s\n", "PID", "CMD", "D", "BYTES");
     74  1.1  christos 	printa("%6d %-16s %1s %@d\n", @total);
     75  1.1  christos }
     76