I'm hacking around with CPU utilization numbers from /proc/stat with this little script:
# cat getticks #!/bin/bash echo "getting one set of data" statOut1=`egrep '^cpu ' /proc/stat` echo "sleeping 5 seconds and getting another set of data" sleep 5 statOut2=`egrep '^cpu ' /proc/stat` nums1=`echo "$statOut1" | grep ^cpu | sed -e 's/cpu\s*//g' -e 's/ /+/g'` let sum1=$nums1 nums2=`echo "$statOut2" | grep ^cpu | sed -e 's/cpu\s*//g' -e 's/ /+/g'` let sum2=$nums2 let totalTicks=$sum2-$sum1 echo "statOut1 = $statOut1" echo "statOut2 = $statOut2" echo "nums1 = $nums1" echo "nums2 = $nums2" echo "totalTicks = $totalTicks" On a SLES 11 SP2 system, with 5 vCPUs, I get the expected output: # ./getticks getting one set of data sleeping 5 seconds and getting another set of data statOut1 = cpu 251 8 170 857508 145 2 7 32 0 0 statOut2 = cpu 251 8 170 860009 145 2 7 32 0 0 nums1 = 251+8+170+857508+145+2+7+32+0+0 nums2 = 251+8+170+860009+145+2+7+32+0+0 totalTicks = 2501 2501 ~= 5 seconds * 5 CPUs * 100 ticks/sec On a RHEL 6.3 system (2 vCPUs), I get a *slightly* different number: # ./getticks getting one set of data sleeping 5 seconds and getting another set of data statOut1 = cpu 13059 57057 56528 4 0 2740 3152 3130 0 statOut2 = cpu 13059 57057 56529 4 0 2740 3152 3130 0 nums1 = 13059+57057+56528+4+0+2740+3152+3130+0 nums2 = 13059+57057+56529+4+0+2740+3152+3130+0 totalTicks = 1 HUH? Does RHEL not count ticks in /proc/stat? Any help will be appreciated. "Mike MacIsaac" <mikemac at-sign us.ibm.com> ---------------------------------------------------------------------- For LINUX-390 subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO LINUX-390 or visit http://www.marist.edu/htbin/wlvindex?LINUX-390 ---------------------------------------------------------------------- For more information on Linux on System z, visit http://wiki.linuxvm.org/
