CPU information on Solaris is obtained using the kstat (kernel statistics) system API.
Basic CPU information about the chip can be obtained using the kstat command-line utility:
kstat -m cpu_info
CPU usage details are stored in kstat as an incrementing count of "ticks", with a seperate count for each CPU state (idle,user,kernel,wait). When a CPU spends a tick in a particular state, this count is incremented. To calculate CPU usage Netprobe computes the difference in tick counts from the values recorded at the previous sample. These figures then represent the CPU details for the sample period, and are displayed to the user as percentages of the total tick count.
For example (fake figures):
- Sample at 12:20:00 - idle 77 ticks, user 16 ticks, kernel 4 ticks, wait 6 ticks
- Sample at 12:20:20 - idle 108 ticks, user 31 ticks, kernel 12 ticks, wait 17 ticks
Therefore for the period of 20s from 12:20:00 to 12:20:20 the CPU performed:
- idle (108-77)=31 ticks, user (31-16)=15 ticks, kernel (12-4)=8 ticks, wait (17-6)=11 ticks
- The total number of ticks during this period of time was: (31+15+8+11)=65 ticks
As percentages, these figures are:
*idle (31/65*100) = 47.7% *user (15/65*100) = 23.0% *kernel (8/65*100) = 12.3% *wait (11/65*100) = 17.0%
Figures for the Average_cpu row are computed by summing all tick counts for physical CPUs, and performing the calculations as per the above.
The raw (uncomputed) tick count figures can also be obtained from the command line. The command to run is:
kstat -m cpu_stat