#!/usr/sbin/dtrace -Cqs long milliintr; BEGIN { printf("Measure usr/sys/intr/idle on a system in per thousand of a CPU\n\n"); usr = 0; sys = 0; intr = 0; idle = 0; ticks = 0; t0 = timestamp; t00 = t0; cpux = cpu; } profile-1ms { usr += (arg1 != 0) ? 1 : 0; sys += (arg0 != 0) ? 1 : 0; /* usr + intr +idle */ idle += (curthread == curthread->t_cpu->cpu_idle_thread) ? 1 : 0; intr += ((curthread->t_cpu->cpu_intr_actv - 16384) > 0) ? 1 : 0; ticks += (cpu == cpux) ? 1 : 0; } tick-1s { musr = (1000 * usr) / ticks; msys = (1000 * (sys - intr - idle)) / ticks; midle = (1000 * idle) / ticks; mintr = (1000 * intr) / ticks; mtot = musr + msys + mintr + midle; busy = musr + msys + mintr; printf("%-8s %-8s %-8s %-8s %-8s %-8s\n","BUSY","USR","SYS","INTR","IDLE","TOTAL"); printf("===================================================\n"); printf("%-8d %-8d %-8d %-8d %-8d %-8d\n\n\n", busy,musr,msys,mintr,midle,mtot); idle = 0; usr = 0; intr = 0; sys = 0; ticks = 0; t0 = timestamp; }