#!/bin/bash
/usr/bin/kstat -m cpu_info | egrep "chip_id|core_id|module: cpu_info" > /var/tmp/cpu_info.log
nproc=`(grep chip_id /var/tmp/cpu_info.log | awk '{ print $2 }' | sort -u | wc -l | tr -d ' ')`
ncore=`(grep core_id /var/tmp/cpu_info.log | awk '{ print $2 }' | sort -u | wc -l | tr -d ' ')`
vproc=`(grep 'module: cpu_info' /var/tmp/cpu_info.log | awk '{ print $4 }' | sort -u | wc -l | tr -d ' ')`
nstrandspercore=$(($vproc/$ncore))
ncoresperproc=$(($ncore/$nproc))
speedinmhz=`(/usr/bin/kstat -m cpu_info | grep clock_MHz | awk '{ print $2 }' | sort -u)`
speedinghz=`echo "scale=2; $speedinmhz/1000" | bc`
echo "Total number of physical processors: $nproc"
echo "Number of virtual processors: $vproc"
echo "Total number of cores: $ncore"
echo "Number of cores per physical processor: $ncoresperproc"
echo "Number of hardware threads (strands or vCPUs) per core: $nstrandspercore"
echo "Processor speed: $speedinmhz MHz ($speedinghz GHz)"
# now derive the vcpu-to-core mapping based on above information #
echo -e "\n** Socket-Core-vCPU mapping **"
let linenum=2
for ((i = 1; i <= ${nproc}; ++i ))
do
chipid=`sed -n ${linenum}p /var/tmp/cpu_info.log | awk '{ print $2 }'`
echo -e "\nPhysical Processor $i (chip id: $chipid):"
for ((j = 1; j <= ${ncoresperproc}; ++j ))
do
let linenum=($linenum + 1)
coreid=`sed -n ${linenum}p /var/tmp/cpu_info.log | awk '{ print $2 }'`
echo -e "\tCore $j (core id: $coreid):"
let linenum=($linenum - 2)
vcpustart=`sed -n ${linenum}p /var/tmp/cpu_info.log | awk '{ print $4 }'`
let linenum=(3 * $nstrandspercore + $linenum - 3)
vcpuend=`sed -n ${linenum}p /var/tmp/cpu_info.log | awk '{ print $4 }'`
echo -e "\t\tvCPU ids: $vcpustart - $vcpuend"
let linenum=($linenum + 4)
done
done
rm /var/tmp/cpu_info.log
/usr/bin/kstat -m cpu_info | egrep "chip_id|core_id|module: cpu_info" > /var/tmp/cpu_info.log
nproc=`(grep chip_id /var/tmp/cpu_info.log | awk '{ print $2 }' | sort -u | wc -l | tr -d ' ')`
ncore=`(grep core_id /var/tmp/cpu_info.log | awk '{ print $2 }' | sort -u | wc -l | tr -d ' ')`
vproc=`(grep 'module: cpu_info' /var/tmp/cpu_info.log | awk '{ print $4 }' | sort -u | wc -l | tr -d ' ')`
nstrandspercore=$(($vproc/$ncore))
ncoresperproc=$(($ncore/$nproc))
speedinmhz=`(/usr/bin/kstat -m cpu_info | grep clock_MHz | awk '{ print $2 }' | sort -u)`
speedinghz=`echo "scale=2; $speedinmhz/1000" | bc`
echo "Total number of physical processors: $nproc"
echo "Number of virtual processors: $vproc"
echo "Total number of cores: $ncore"
echo "Number of cores per physical processor: $ncoresperproc"
echo "Number of hardware threads (strands or vCPUs) per core: $nstrandspercore"
echo "Processor speed: $speedinmhz MHz ($speedinghz GHz)"
# now derive the vcpu-to-core mapping based on above information #
echo -e "\n** Socket-Core-vCPU mapping **"
let linenum=2
for ((i = 1; i <= ${nproc}; ++i ))
do
chipid=`sed -n ${linenum}p /var/tmp/cpu_info.log | awk '{ print $2 }'`
echo -e "\nPhysical Processor $i (chip id: $chipid):"
for ((j = 1; j <= ${ncoresperproc}; ++j ))
do
let linenum=($linenum + 1)
coreid=`sed -n ${linenum}p /var/tmp/cpu_info.log | awk '{ print $2 }'`
echo -e "\tCore $j (core id: $coreid):"
let linenum=($linenum - 2)
vcpustart=`sed -n ${linenum}p /var/tmp/cpu_info.log | awk '{ print $4 }'`
let linenum=(3 * $nstrandspercore + $linenum - 3)
vcpuend=`sed -n ${linenum}p /var/tmp/cpu_info.log | awk '{ print $4 }'`
echo -e "\t\tvCPU ids: $vcpustart - $vcpuend"
let linenum=($linenum + 4)
done
done
rm /var/tmp/cpu_info.log
Sample output
oracle:/export/home/oracle>./proc.sh
Total number of physical processors: 1
Number of virtual processors: 64
Total number of cores: 8
Number of cores per physical processor: 8
Number of hardware threads (strands or vCPUs) per core: 8
Processor speed: 2848 MHz (2.84 GHz)
** Socket-Core-vCPU mapping **
Physical Processor 1 (chip id: 0):
Core 1 (core id: 1026):
vCPU ids: 0 - 7
Core 2 (core id: 1030):
vCPU ids: 8 - 15
Core 3 (core id: 1034):
vCPU ids: 16 - 23
Core 4 (core id: 1038):
vCPU ids: 24 - 31
Core 5 (core id: 1042):
vCPU ids: 32 - 39
Core 6 (core id: 1046):
vCPU ids: 40 - 47
Core 7 (core id: 1050):
vCPU ids: 48 - 55
Core 8 (core id: 1054):
vCPU ids: 56 - 63
No comments:
Post a Comment