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 * $Id: runocc.d,v 1.1.1.1 2015/09/30 22:01:06 christos Exp $
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 * 24-Apr-2006	   "      "	Last update.
40 */
41
42#pragma D option quiet
43
44profile-1000hz
45/curthread->t_cpu->cpu_disp->disp_nrunnable/
46{
47	@qocc[cpu] = count();
48}
49
50profile:::tick-1sec
51{
52	normalize(@qocc, 10);
53	printf("\n%8s %8s\n", "CPU", "%runocc");
54	printa("%8d %@8d\n", @qocc);
55	clear(@qocc);
56}
57