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
1N/A # ./cputimes 1 3
1N/A 2005 Apr 27 23:37:58,
1N/A THREADS TIME (ns)
1N/A KERNEL 10795499
1N/A PROCESS 20941091
1N/A IDLE 970707443
1N/A 2005 Apr 27 23:37:59,
1N/A THREADS TIME (ns)
1N/A KERNEL 8919418
1N/A PROCESS 77446789
1N/A IDLE 910555040
1N/A 2005 Apr 27 23:38:00,
1N/A THREADS TIME (ns)
1N/A KERNEL 8615123
1N/A PROCESS 78314246
1N/A IDLE 810100417
1N/A
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/A
1N/A
1N/A
1N/A
1N/AIn the following example, several programs are run to hog the CPUs,
1N/A
1N/A # ./cputimes 1 3
1N/A 2005 Apr 27 23:40:58,
1N/A THREADS TIME (ns)
1N/A KERNEL 11398807
1N/A PROCESS 992254664
1N/A 2005 Apr 27 23:40:59,
1N/A THREADS TIME (ns)
1N/A KERNEL 9205260
1N/A PROCESS 987561182
1N/A 2005 Apr 27 23:41:00,
1N/A THREADS TIME (ns)
1N/A KERNEL 9196669
1N/A PROCESS 877850474
1N/A
1N/ANow there is no IDLE category, as the system is 100% utilised.
1N/AThe programs were the following,
1N/A
1N/A while :; do :; done &
1N/A
1N/Awhich keeps the CPU busy.
1N/A
1N/A
1N/A
1N/A
1N/AIn the following example a different style of program is run to hog the CPUs,
1N/A
1N/A while :; do date; done
1N/A
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
1N/A # ./cputimes 1 3
1N/A 2005 Apr 27 23:45:30,
1N/A THREADS TIME (ns)
1N/A KERNEL 192647392
1N/A PROCESS 835397568
1N/A 2005 Apr 27 23:45:31,
1N/A THREADS TIME (ns)
1N/A KERNEL 168773713
1N/A PROCESS 810825730
1N/A 2005 Apr 27 23:45:32,
1N/A THREADS TIME (ns)
1N/A KERNEL 151676122
1N/A PROCESS 728477272
1N/A
1N/ANow the kernel is doing a substantial amount of work to create and destroy
1N/Athese processes.
1N/A
1N/A
1N/A
1N/A
1N/AIn the following example, a large amount of network activity occurs while
1N/Acputimes is running,
1N/A
1N/A # ./cputimes 1 6
1N/A 2005 Apr 27 23:49:29,
1N/A THREADS TIME (ns)
1N/A KERNEL 10596399
1N/A PROCESS 21793920
1N/A IDLE 974395713
1N/A 2005 Apr 27 23:49:30,
1N/A THREADS TIME (ns)
1N/A KERNEL 251465759
1N/A IDLE 357436576
1N/A PROCESS 508986422
1N/A 2005 Apr 27 23:49:31,
1N/A THREADS TIME (ns)
1N/A IDLE 9758227
1N/A KERNEL 367645318
1N/A PROCESS 385427847
1N/A 2005 Apr 27 23:49:32,
1N/A THREADS TIME (ns)
1N/A IDLE 28351679
1N/A KERNEL 436022725
1N/A PROCESS 451304688
1N/A 2005 Apr 27 23:49:33,
1N/A THREADS TIME (ns)
1N/A KERNEL 262586158
1N/A PROCESS 325238896
1N/A IDLE 358243503
1N/A 2005 Apr 27 23:49:34,
1N/A THREADS TIME (ns)
1N/A KERNEL 10075578
1N/A PROCESS 238170506
1N/A IDLE 647956998
1N/A
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/A
1N/A
1N/A
1N/A
1N/ALonger samples are possible. The following is a 60 second sample,
1N/A
1N/A # ./cputimes 60 1
1N/A 2005 Apr 27 23:53:02,
1N/A THREADS TIME (ns)
1N/A KERNEL 689808449
1N/A PROCESS 8529562214
1N/A IDLE 50406951876
1N/A #
1N/A
1N/A
1N/A
1N/A
1N/Acputimes has a "-a" option to print all processes. The following is a
1N/Asingle 1 second sample with -a,
1N/A
1N/A # ./cputimes -a 1 1
1N/A 2005 Apr 28 00:00:32,
1N/A THREADS TIME (ns)
1N/A svc.startd 51042
1N/A nautilus 130645
1N/A in.routed 131823
1N/A fmd 152822
1N/A nscd 307042
1N/A dsdm 415799
1N/A mixer_applet2 551066
1N/A gnome-smproxy 587234
1N/A xscreensaver 672270
1N/A fsflush 1060196
1N/A java_vm 1552988
1N/A wnck-applet 2060870
1N/A dtrace 2398658
1N/A acroread 2614687
1N/A soffice.bin 2825117
1N/A mozilla-bin 5497488
1N/A KERNEL 13541120
1N/A metacity 28924204
1N/A gnome-terminal 74304348
1N/A Xorg 289631407
1N/A IDLE 465054209
1N/A
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/Asvc.startd ran for 51 microseconds, and soffice.bin ran for 28 milliseconds.
1N/A
1N/A
1N/A
1N/A
1N/AThe following is a 10 second sample on an idle desktop,
1N/A
1N/A # ./cputimes -a 10 1
1N/A 2005 Apr 28 00:03:57,
1N/A THREADS TIME (ns)
1N/A snmpd 127859
1N/A fmd 171897
1N/A inetd 177134
1N/A svc.configd 185006
1N/A mapping-daemon 197674
1N/A miniserv.pl 305603
1N/A gconfd-2 330511
1N/A xscreensaver 443207
1N/A sendmail 473434
1N/A nautilus 506799
1N/A gnome-vfs-daemon 549037
1N/A gnome-panel 770631
1N/A nscd 885353
1N/A svc.startd 1181286
1N/A gnome-netstatus- 4329671
1N/A mixer_applet2 4833519
1N/A dtrace 6244366
1N/A in.routed 6556075
1N/A fsflush 9553155
1N/A soffice.bin 13954327
1N/A java_vm 16285243
1N/A acroread 32126193
1N/A gnome-terminal 34891991
1N/A Xorg 35553412
1N/A mozilla-bin 67855629
1N/A KERNEL 94834997
1N/A IDLE 9540941846
1N/A
1N/AWow, maybe not as idle as I thought!
1N/A
1N/A
1N/A