1235368Sgnn#!/usr/sbin/dtrace -s 2235368Sgnn/* 3235368Sgnn * runocc.d - run queue occupancy by CPU. 4235368Sgnn * Written using DTrace (Solaris 10 3/05). 5235368Sgnn * 6235368Sgnn * This prints the dispatcher run queue occupancy by CPU each second. 7235368Sgnn * A consistant run queue occupancy is a sign of CPU saturation. 8235368Sgnn * 9235368Sgnn * The value is similar to that seen in "sar -q", however this is 10235368Sgnn * calculated in a more accurate manner - sampling at 1000 Hertz. 11235368Sgnn * 12235368Sgnn * $Id: runocc.d 3 2007-08-01 10:50:08Z brendan $ 13235368Sgnn * 14235368Sgnn * USAGE: runocc.d 15235368Sgnn * 16235368Sgnn * FIELDS: 17235368Sgnn * CPU cpu ID 18235368Sgnn * %runocc % run queue occupancy, sampled at 1000 Hertz 19235368Sgnn * 20235368Sgnn * SEE ALSO: Solaris Internals 2nd Ed, vol 2, CPU chapter. 21235368Sgnn * 22235368Sgnn * COPYRIGHT: Copyright (c) 2006 Brendan Gregg. 23235368Sgnn * 24235368Sgnn * CDDL HEADER START 25235368Sgnn * 26235368Sgnn * The contents of this file are subject to the terms of the 27235368Sgnn * Common Development and Distribution License, Version 1.0 only 28235368Sgnn * (the "License"). You may not use this file except in compliance 29235368Sgnn * with the License. 30235368Sgnn * 31235368Sgnn * You can obtain a copy of the license at Docs/cddl1.txt 32235368Sgnn * or http://www.opensolaris.org/os/licensing. 33235368Sgnn * See the License for the specific language governing permissions 34235368Sgnn * and limitations under the License. 35235368Sgnn * 36235368Sgnn * CDDL HEADER END 37235368Sgnn * 38235368Sgnn * 02-Mar-2006 Brendan Gregg Created this. 39235368Sgnn * 24-Apr-2006 " " Last update. 40235368Sgnn */ 41235368Sgnn 42235368Sgnn#pragma D option quiet 43235368Sgnn 44235368Sgnnprofile-1000hz 45235368Sgnn/curthread->t_cpu->cpu_disp->disp_nrunnable/ 46235368Sgnn{ 47235368Sgnn @qocc[cpu] = count(); 48235368Sgnn} 49235368Sgnn 50235368Sgnnprofile:::tick-1sec 51235368Sgnn{ 52235368Sgnn normalize(@qocc, 10); 53235368Sgnn printf("\n%8s %8s\n", "CPU", "%runocc"); 54235368Sgnn printa("%8d %@8d\n", @qocc); 55235368Sgnn clear(@qocc); 56235368Sgnn} 57