pridist.d revision 272461
1210967Spjd#!/usr/sbin/dtrace -s 2210967Spjd/* 3210967Spjd * pridist.d - process priority distribution. 4210967Spjd * Written using DTrace (Solaris 10 3/05) 5210967Spjd * 6210967Spjd * This is a simple DTrace script that samples at 1000 Hz which process 7210967Spjd * is on the CPUs, and what the priority is. A distribution plot is printed. 8210967Spjd * 9210967Spjd * With priorities, the higher the priority the better chance the process 10210967Spjd * (actually, thread) has of being scheduled. 11210967Spjd * 12210967Spjd * This idea came from the script /usr/demo/dtrace/profpri.d, which 13210967Spjd * produces similar output for one particular PID. 14210967Spjd * 15210967Spjd * $Id: pridist.d 3 2007-08-01 10:50:08Z brendan $ 16210967Spjd * 17210967Spjd * USAGE: pridist.d # hit Ctrl-C to end sampling 18210967Spjd * 19210967Spjd * FIELDS: 20210967Spjd * CMD process name 21210967Spjd * PID process ID 22210967Spjd * value process priority 23210967Spjd * count number of samples of at least this priority 24210967Spjd * 25210967Spjd * BASED ON: /usr/demo/dtrace/profpri.d 26210967Spjd * 27210967Spjd * SEE ALSO: 28210967Spjd * DTrace Guide "profile Provider" chapter (docs.sun.com) 29210967Spjd * dispadmin(1M) 30210967Spjd * 31210967Spjd * PORTIONS: Copyright (c) 2005 Brendan Gregg. 32210967Spjd * 33210967Spjd * CDDL HEADER START 34210967Spjd * 35210967Spjd * The contents of this file are subject to the terms of the 36210967Spjd * Common Development and Distribution License, Version 1.0 only 37210967Spjd * (the "License"). You may not use this file except in compliance 38210967Spjd * with the License. 39210967Spjd * 40210967Spjd * You can obtain a copy of the license at Docs/cddl1.txt 41210967Spjd * or http://www.opensolaris.org/os/licensing. 42210967Spjd * See the License for the specific language governing permissions 43210967Spjd * and limitations under the License. 44210967Spjd * 45210967Spjd * CDDL HEADER END 46210967Spjd * 47210967Spjd * 13-Jun-2005 Brendan Gregg Created this. 48210967Spjd * 22-Apr-2006 " " Last update. 49210967Spjd */ 50210967Spjd 51210967Spjd#pragma D option quiet 52210967Spjd 53210967Spjddtrace:::BEGIN 54210967Spjd{ 55210967Spjd printf("Sampling... Hit Ctrl-C to end.\n"); 56210967Spjd} 57210967Spjd 58210967Spjdprofile:::profile-1000hz 59210967Spjd{ 60210967Spjd @Count[execname, pid] = lquantize(curlwpsinfo->pr_pri, 0, 170, 5); 61210967Spjd} 62210967Spjd 63210967Spjddtrace:::END 64210967Spjd{ 65 printa(" CMD: %-16s PID: %d\n%@d\n", @Count); 66} 67