3 * loads.d - print load averages. Written using DTrace (Solaris 10 3/05).
5 * These are the same load averages that the "uptime" command prints.
6 * The purpose of this script is to demonstrate fetching these values
7 * from the DTrace language.
9 * $Id: loads.d 3 2007-08-01 10:50:08Z brendan $
15 * The first field is the 1 minute average, the second is the 5 minute,
16 * and the third is the 15 minute average. The value represents the average
17 * number of runnable threads in the system, a value higher than your
18 * CPU (core/hwthread) count may be a sign of CPU saturation.
20 * COPYRIGHT: Copyright (c) 2005 Brendan Gregg.
24 * The contents of this file are subject to the terms of the
25 * Common Development and Distribution License, Version 1.0 only
26 * (the "License"). You may not use this file except in compliance
29 * You can obtain a copy of the license at Docs/cddl1.txt
30 * or http://www.opensolaris.org/os/licensing.
31 * See the License for the specific language governing permissions
32 * and limitations under the License.
36 * 10-Jun-2005 Brendan Gregg Created this.
37 * 10-Jun-2005 " " Last update.
40 #pragma D option quiet
44 /* fetch load averages */
45 this->load1a = `hp_avenrun[0] / 65536;
46 this->load5a = `hp_avenrun[1] / 65536;
47 this->load15a = `hp_avenrun[2] / 65536;
48 this->load1b = ((`hp_avenrun[0] % 65536) * 100) / 65536;
49 this->load5b = ((`hp_avenrun[1] % 65536) * 100) / 65536;
50 this->load15b = ((`hp_avenrun[2] % 65536) * 100) / 65536;
52 /* print load average */
53 printf("%Y, load average: %d.%02d, %d.%02d, %d.%02d\n",
54 walltimestamp, this->load1a, this->load1b, this->load5a,
55 this->load5b, this->load15a, this->load15b);