1N/AThe following demonstrates running the cputimes program on an idle system.
1N/AWe use an interval of 1 second and a count of 3,
1N/A 2005 Apr 27 23:37:58,
1N/A 2005 Apr 27 23:37:59,
1N/A 2005 Apr 27 23:38:00,
1N/AIn the above output, we can see a breakdown of CPU time into the catagories
1N/AKERNEL, PROCESS and IDLE. The time is measured in nanoseconds. Most of the
1N/Atime is in the IDLE category, as the system is idle. Very little time
1N/Awas spent serving the kernel.
1N/AIn the following example, several programs are run to hog the CPUs,
1N/A 2005 Apr 27 23:40:58,
1N/A 2005 Apr 27 23:40:59,
1N/A 2005 Apr 27 23:41:00,
1N/ANow there is no IDLE category, as the system is 100% utilised.
1N/AThe programs were the following,
1N/A while :; do :; done &
1N/Awhich keeps the CPU busy.
1N/AIn the following example a different style of program is run to hog the CPUs,
1N/A while :; do date; done
1N/AThis causes many processes to be created and destroyed in a hurry, and can
1N/Abe difficult to troubleshoot (tools like prstat cannot sample quick enough
1N/Ato easily identify what is going on). The following is the cputimes output,
1N/A 2005 Apr 27 23:45:30,
1N/A 2005 Apr 27 23:45:31,
1N/A 2005 Apr 27 23:45:32,
1N/ANow the kernel is doing a substantial amount of work to create and destroy
1N/AIn the following example, a large amount of network activity occurs while
1N/A 2005 Apr 27 23:49:29,
1N/A 2005 Apr 27 23:49:30,
1N/A 2005 Apr 27 23:49:31,
1N/A 2005 Apr 27 23:49:32,
1N/A 2005 Apr 27 23:49:33,
1N/A 2005 Apr 27 23:49:34,
1N/AInitially the system is idle. A command is run to cause heavy network
1N/Aactivity, which peaks during the fourth sample - during which the kernel
1N/Ais using around 40% of the CPU. The Solaris 10 command "intrstat" can
1N/Ahelp to analyse this activity further.
1N/ALonger samples are possible. The following is a 60 second sample,
1N/A 2005 Apr 27 23:53:02,
1N/Acputimes has a "-a" option to print all processes. The following is a
1N/Asingle 1 second sample with -a,
1N/A 2005 Apr 28 00:00:32,
1N/A mixer_applet2 551066
1N/A gnome-smproxy 587234
1N/A gnome-terminal 74304348
1N/AThe times are in nanoseconds, and multiple processes with the same name
1N/Ahave their times aggregated. The above output is at an amazing resolution -
1N/AThe following is a 10 second sample on an idle desktop,
1N/A # ./cputimes -a 10 1
1N/A 2005 Apr 28 00:03:57,
1N/A mapping-daemon 197674
1N/A gnome-vfs-daemon 549037
1N/A gnome-netstatus- 4329671
1N/A mixer_applet2 4833519
1N/A gnome-terminal 34891991
1N/A mozilla-bin 67855629
1N/AWow, maybe not as idle as I thought!