LANG="en_US.UTF-8"
# accelerated_cpus are the cpus that app running on
accelerated_cpus="1 2 3"
# 获取当前时间
ttime=`date +"%Y-%m-%d_%H-%M"`
echo "Testing_time:$ttime"
# 执行性能测试的设备
declare -i test_device_name
test_device_name=0
device_name="swiftn$test_device_name"
device_interface=0
echo "Default Test device_name=$device_name"
echo "Default Test device_interface=$device_interface"
# 判断是否安装驱动 为获得版本号
if ! command -v yusur_ctl >/dev/null 2>&1; then
echo "yusur_ctl not found or cannot be started"
else
first_row=$((`yusur_ctl -v| grep -n "Device swiftn[0-9]*" | awk 'NR==1' | awk -F: '{print $1}'`))
lat_row=$((`yusur_ctl -v| grep -n "Device swiftn[0-9]*" | awk 'NR==2' | awk -F: '{print $1}'`))
max_row=$((`yusur_ctl -v| wc -l`))
# 判断一张板卡设备的详情一共有多少行
if [ $lat_row == 0 ];then
diff_row=$(($max_row - $first_row))
# echo "m $diff_row"
else
diff_row=$(($lat_row - $first_row - 1))
# echo "l $diff_row"
fi
# 获得版本号
net_card_msg=`yusur_ctl -v| grep -A$diff_row "$device_name"`
net_card_firmware_version=`yusur_ctl -v| grep -A$diff_row "$device_name" | grep "Firmware version" | awk '{print $3}'`
net_card_swiftn_version=`yusur_ctl -v| grep -A$diff_row "$device_name" | grep "swiftn.ko" | awk '{print $3}'`
net_card_instanta_version=`yusur_ctl -v| grep -A$diff_row "$device_name" | grep "instanta.ko" | awk '{print $3}'`
net_card_libinstanta_version=`yusur_ctl -v| grep -A$diff_row "$device_name" | grep "libinstanta.so" | awk '{print $3}'`
# 版本号输出排版
net_card_version="Firmware=$net_card_firmware_version"
swiftn_driver="swiftn.ko=$net_card_swiftn_version"
kernel_module="instanta.ko=$net_card_instanta_version"
lib="libinstanta.so=$net_card_libinstanta_version"
# 输出 操作系统 检查结果记录
echo ""
echo "---OS version check------------------"
sa_version="`uname -m`"
os_version="`cat /etc/os-release | grep "PRETTY_NAME=" | awk -F'"' '{print $2}'`"
os_version=(${os_version// /_})
cpu_model="`cat /proc/cpuinfo | grep "model name" | awk 'NR==1' | cut -d" " -f3-`"
cpu_model=(${cpu_model// /_})
printf "SA_version=\e[1;31m%s\e[0m\n" $sa_version
echo "Cpu_model_name=$cpu_model"
printf "OS_version=\e[1;31m%s\e[0m\n" $os_version
# 输出 lspci 检查结果记录
echo ""
echo "---Yusur Network Card paramet check--"
yusur_nic_pci_bdf=`lspci -D | grep -E "Yusur|Xilinx|1f47" | awk '{print $1}'`
declare -i i_nr
declare -i card_num
i_nr=1
card_num=0
# 遍历含有yusur信息的设备
for nic_bdf in $yusur_nic_pci_bdf
do
echo "Yusur NIC pci number:$nic_bdf"
if [ $card_num == $test_device_name ]
then
test_card_bdf=$nic_bdf
fi
echo " Numa: `cat /sys/bus/pci/devices/$nic_bdf/numa_node`"
nic_bdf_int=$((16#${nic_bdf:5:2}+0))
device_name_pci=` yusur_ctl | grep -E "swiftn[0-9]*:" | awk "NR==$i_nr" `
device_name_pci=${device_name_pci:0:-1}
echo " Device_name:$device_name_pci"
echo " Base_addr[size=16M]:`lspci -v -s $nic_bdf | grep Memory | awk '{print $3}' | awk 'NR==1'`"
echo " LnkSta: `lspci -vv -s $nic_bdf | grep LnkSta: | awk '{print $2, $3, $5, $6}'`"
i_nr+=1
card_num+=1
done
declare -i cpu_num
# 遍历中断状态
echo "Interruption Status:"
nic_irq_num=`cat /proc/interrupts | grep swiftn | wc -l`
for ((i=0;i<nic_irq_num;i++))
do
nic_irq=`cat /proc/interrupts | grep swiftn| awk "NR==$((i+1))" |awk '{print $1}'| awk '{t=length($0)}END{print substr($0, 0, t-1)}' `
nic_irq_name=`cat /proc/interrupts | grep swiftn| awk "NR==$((i+1))" |awk '{print $NF}'`
if [ ! -n "$nic_irq" ] ; then
echo " Interrupt is Null"
else
echo " $nic_irq_name Interrupt: $nic_irq"
echo " Irq affinity: `cat /proc/irq/$nic_irq/smp_affinity_list`"
fi
done
cpu_num=`cat /proc/cpuinfo | grep processor | wc -l`
interrupts_leng=` cat /proc/interrupts | grep swiftn | awk "NR==1" | awk '{print NF}' `
other_info_leng=$(($interrupts_leng-$cpu_num-1))
info_leng=$(($other_info_leng+$cpu_num))
i=0
printf "IRQ Details:\n"
for cpu_i in `cat /proc/interrupts | grep swiftn`
do
if (( $i < $info_leng))
then
((i++))
if (( i == 1 ))
then
echo " $cpu_i"
elif (( i > 1 )) && ((i < $((cpu_num+2)) ))
then
k=$(($cpu_i))
# k=$cpu_i
interrupt=$(($i-2))
# printf "%s:%s " $interrupt $k
if test $k -ne 0;then
printf " code:%s-IRQ_num:%s \n" $interrupt $k
fi
else
sleep 0.01
fi
else
echo " *** BOTTOM ****************"
i=0
fi
done
# 输出 yusur_ctl 检查结果记录
echo ""
echo "---Yusur Network Card config check---"
net_card_num=$((`yusur_ctl -v| grep -n "Device swiftn.*" | wc -l`))
echo "Number of network cards:$net_card_num"
# 输出执行性能测试设备的版本信息
declare -i i
i=0
ls /dev/swiftn*| awk -F'/' '{print $3}'| while read line
do
echo " dev_name[$i]:$line"
i=i+1
done
echo "`yusur_ctl -v| grep "$device_name"` "
echo " $net_card_version"
echo " $swiftn_driver"
echo " $kernel_module"
echo " $lib"
# test_card_bdf 文件头设置的测试网卡bdf
interface_0=` ls /sys/bus/pci/devices/$test_card_bdf/net | awk "NR==1" `
interface_1=` ls /sys/bus/pci/devices/$test_card_bdf/net | awk "NR==2" `
# 收集测试网卡的接口信息
echo " `yusur_ctl -v| grep -A$diff_row "$device_name" | grep "$interface_0" ` "
mtu_0=`ifconfig $interface_0 |grep mtu |awk '{print $NF}'`
echo " MTU:$mtu_0"
if [ ` ethtool -c $interface_0 >/dev/null 2>&1 || echo $? ` ];then
echo " rx-usecs:N/A"
else
rx_usecs=` ethtool -c $interface_0 | grep "rx-usecs:" | cut -d" " -f2- `
echo " rx-usecs:$rx_usecs"
fi
loopback_mode=`yusur_ctl -v| grep -A$diff_row "$device_name" | grep -A 12 "$interface_0" | grep "Loopback mode:" | awk '{print $3}'`
echo " Loopback_mode:$loopback_mode"
# promiscuous_mode=`yusur_ctl -v| grep -A$diff_row "$device_name" | grep -A 12 "$interface_0" | grep "Promiscuous mode:" | awk '{print $3}'`
# echo " Promiscuous_mode:$promiscuous_mode"
Kernel_bypass_mode=`yusur_ctl -v| grep -A$diff_row "$device_name" | grep -A 12 "$interface_0" | grep "Kernel-bypass mode:" | awk '{print $3}'`
echo " Kernel-bypass_mode:$Kernel_bypass_mode"
ip=`yusur_ctl -v| grep -A$diff_row "$device_name" | grep -A 12 "$interface_0" | grep "inet:" | awk '{print $2}'`
echo " IP address:$ip"
echo " `yusur_ctl -v| grep -A$diff_row "$device_name" | grep "$interface_1" ` "
mtu_1=`ifconfig $interface_1 |grep mtu |awk '{print $NF}'`
echo " MTU:$mtu_1"
if [ ` ethtool -c $interface_1 >/dev/null 2>&1 || echo $? ` ];then
echo " rx-usecs:N/A"
else
rx_usecs=` ethtool -c $interface_1 | grep "rx-usecs:" | cut -d" " -f2- `
echo " rx-usecs:$rx_usecs"
fi
loopback_mode=`yusur_ctl -v| grep -A$diff_row "$device_name" | grep -A 12 "$interface_1" | grep "Loopback mode:" | awk '{print $3}'`
echo " Loopback_mode:$loopback_mode"
# promiscuous_mode=`yusur_ctl -v| grep -A$diff_row "$device_name" | grep -A 12 "$interface_1" | grep "Promiscuous mode:" | awk '{print $3}'`
# echo " Promiscuous_mode:$promiscuous_mode"
Kernel_bypass_mode=`yusur_ctl -v| grep -A$diff_row "$device_name" | grep -A 12 "$interface_1" | grep "Kernel-bypass mode:" | awk '{print $3}'`
echo " Kernel-bypass_mode:$Kernel_bypass_mode"
ip=`yusur_ctl -v| grep -A$diff_row "$device_name" | grep -A 12 "$interface_1" | grep "inet:" | awk '{print $2}'`
echo " IP address:$ip"
fi
# 输出 dmidecode 检查结果记录
echo ""
echo "---DIMM check------------------------"
mem=`dmidecode -t memory | grep -A5 "Memory Device" | grep "Size"`
mem_total_slot=`dmidecode -t memory | grep -A5 "Memory Device" | grep "Size" | wc -l`
mem_empty_slot=`dmidecode -t memory | grep -A5 "Memory Device" | grep "Size" | grep "No Module Installed" | wc -l`
if [ $mem_total_slot -ne $mem_empty_slot ]; then
echo " DIMM slots (empty/total): $mem_empty_slot/$mem_total_slot"
echo " DIMM slots : "
dmidecode -t memory | grep -A5 "Memory Device" | grep "Size" | while read line
do
echo " $line"
done
fi
# 输出 lscpu-numa 检查结果记录
echo ""
echo "---Cpu numa check--------------------"
lscpu | grep -E "NUMA node|NUMA 节点" | while read line_cpu
do
echo " $line_cpu"
done
# 输出 cmdline 检查结果记录
echo ""
echo "---Cmdline check---------------------"
isolcpus="`awk '{for(i=1;i<=NF;i++) if($i ~ /isolcpus/) print $i}' /proc/cmdline`"
nohz_full="`awk '{for(i=1;i<=NF;i++) if($i ~ /nohz_full/) print $i}' /proc/cmdline`"
rcu_nocbs="`awk '{for(i=1;i<=NF;i++) if($i ~ /rcu_nocbs/) print $i}' /proc/cmdline`"
iommu="`awk '{for(i=1;i<=NF;i++) if($i ~ /iommu/) print $i}' /proc/cmdline`"
intel_max_cstate="`awk '{for(i=1;i<=NF;i++) if($i ~ /intel_idle.max_cstate/) print $i}' /proc/cmdline`"
amd_max_cstate="`awk '{for(i=1;i<=NF;i++) if($i ~ /processor.max_cstate/) print $i}' /proc/cmdline`"
idle="`awk '{for(i=1;i<=NF;i++) if($i ~ /idle=/) print $i}' /proc/cmdline`"
kthread_cpus="`awk '{for(i=1;i<=NF;i++) if($i ~ /kthread_cpus/) print $i}' /proc/cmdline`"
irqaffinity="`awk '{for(i=1;i<=NF;i++) if($i ~ /irqaffinity/) print $i}' /proc/cmdline`"
intel_pstate="`awk '{for(i=1;i<=NF;i++) if($i ~ /intel_pstate/) print $i}' /proc/cmdline`"
echo " isolcpus : $isolcpus"
echo " nohz_full : $nohz_full"
echo " rcu_nocbs : $rcu_nocbs"
echo " iommu : $iommu"
echo " idle : $idle"
echo " kthread_cpus : $kthread_cpus"
echo " irqaffinity : $irqaffinity"
echo " (Intel) max_cstate : $intel_max_cstate"
echo " (Amd) max_cstate : $amd_max_cstate"
echo " (Intel) pstate : $intel_pstate"
echo ""
echo "---Cpu freq scaling gonernor check---"
for cpu in $accelerated_cpus
do
if [ ! -d "/sys/devices/system/cpu/cpu$cpu/cpufreq/" ] ; then
echo " Cannot find cpu$cpu"
else
echo " cpu$cpu: `cat "/sys/devices/system/cpu/cpu$cpu/cpufreq/scaling_governor"`"
fi
done
# 输出 cpu模式 检查结果记录
echo ""
echo "---Cpu freq check--------------------"
for cpu in $accelerated_cpus
do
if [ ! -d "/sys/devices/system/cpu/cpu$cpu/cpufreq/" ] ; then
echo " Cannot find cpu$cpu"
else
echo " cpu$cpu: `cat "/sys/devices/system/cpu/cpu$cpu/cpufreq/scaling_cur_freq"`"
fi
done
# 输出 cpu频率 检查结果记录
echo ""
echo "---Watchdog check--------------------"
watchdog=`cat /proc/sys/kernel/watchdog`
if [ $watchdog == 1 ];then
echo " Watchdog is open"
else
echo " Watchdog is closed"
fi
echo ""
echo "Test End"
性能测试--检查服务器配置脚本
于 2023-02-14 18:00:30 首次发布