1#!/usr/sbin/dtrace -s 2/* 3 * runocc.d - run queue occupancy by CPU. 4 * Written using DTrace (Solaris 10 3/05). 5 * 6 * This prints the dispatcher run queue occupancy by CPU each second. 7 * A consistant run queue occupancy is a sign of CPU saturation. 8 * 9 * The value is similar to that seen in "sar -q", however this is 10 * calculated in a more accurate manner - sampling at 1000 Hertz. 11 * 12 * 24-Apr-2006, ver 0.70 13 * 14 * USAGE: runocc.d 15 * 16 * FIELDS: 17 * CPU cpu ID 18 * %runocc % run queue occupancy, sampled at 1000 Hertz 19 * 20 * SEE ALSO: Solaris Internals 2nd Ed, vol 2, CPU chapter. 21 * 22 * COPYRIGHT: Copyright (c) 2006 Brendan Gregg. 23 * 24 * CDDL HEADER START 25 * 26 * The contents of this file are subject to the terms of the 27 * Common Development and Distribution License, Version 1.0 only 28 * (the "License"). You may not use this file except in compliance 29 * with the License. 30 * 31 * You can obtain a copy of the license at Docs/cddl1.txt 32 * or http://www.opensolaris.org/os/licensing. 33 * See the License for the specific language governing permissions 34 * and limitations under the License. 35 * 36 * CDDL HEADER END 37 * 38 * 02-Mar-2006 Brendan Gregg Created this. 39 */ 40 41#pragma D option quiet 42 43profile-1000hz 44/curthread->last_processor->runq.count/ 45{ 46 @qocc[cpu] = count(); 47} 48 49profile:::tick-1sec 50{ 51 normalize(@qocc, 10); 52 printf("\n%8s %8s\n", "CPU", "%runocc"); 53 printa("%8d %@8d\n", @qocc); 54 clear(@qocc); 55} 56