【昇腾】NPU Snt9B裸金属服务器MAC、RoCE、NIC收发速率监控方法
【摘要】 笔者使用华为云ModelArts弹性裸金属服务器-Ascend Snt9B服务器,选择的服务器镜像为: EulerOS-2.10-Arm-rc3-64bit-for-Snt9B-BareMetal-with-CANN7.0.RC1Ascend Snt9B服务器中的hccl_tool工具可以查看RoCE网卡的统计信息。本文基本hccl_tool工具,提供用于计算MAC、RoCEE、Nic收发...
1. 背景介绍
笔者使用华为云ModelArts弹性裸金属服务器-Ascend Snt9B服务器,选择的服务器镜像为: EulerOS-2.10-Arm-rc3-64bit-for-Snt9B-BareMetal-with-CANN7.0.RC1
Ascend Snt9B服务器中的hccl_tool工具可以查看RoCE网卡的统计信息。
2. 方案
本文基本hccl_tool工具,提供用于计算MAC(链路层)、RoCE、Nic(网口)收发速率统计指标的脚本:
#!/bin/bash
INTERVAL=60
for id in {0..7}; do
prev_time[$id]=0
prev_mac_tx[$id]=0
prev_mac_rx[$id]=0
prev_rocee_tx[$id]=0
prev_rocee_rx[$id]=0
prev_nic_tx[$id]=0
prev_nic_rx[$id]=0
done
first_loop=1
while true; do
echo "+------------------------------------------------------------------------------------------------------+"
echo "| NPU | Time | MacTX(MB/s) | MacRX(MB/s) | RoCEETX(pps) | RoCEERX(pps) | NicTX(MB/s) | NicRX(MB/s) |"
echo "+------------------------------------------------------------------------------------------------------+"
for devid in {0..7}; do
time=$(date "+%Y-%m-%d %H:%M:%S")
output=$(hccn_tool -i "$devid" -stat -g)
mac_tx=$(echo "$output" | awk -F':' '$1 == "mac_tx_total_oct_num" {print $2}')
mac_rx=$(echo "$output" | awk -F':' '$1 == "mac_rx_total_oct_num" {print $2}')
rocee_tx=$(echo "$output" | awk -F':' '$1 == "roce_tx_all_pkt_num" {print $2}')
rocee_rx=$(echo "$output" | awk -F':' '$1 == "roce_tx_all_pkt_num" {print $2}')
nic_tx=$(echo "$output" | awk -F':' '$1 == "nic_tx_all_oct_num" {print $2}')
nic_rx=$(echo "$output" | awk -F':' '$1 == "nic_rx_all_oct_num" {print $2}')
if [ $first_loop -eq 1 ]; then
printf "| %d |" $devid
printf " ${time:11} |"
printf " 初始化... |\n"
else
duration=$(($(date +%s -d "${time}")-$(date +%s -d "${prev_time[$devid]}")))
mac_tx_incr=$((mac_tx - prev_mac_tx[$devid]))
mac_rx_incr=$((mac_rx - prev_mac_rx[$devid]))
rocee_tx_incr=$((rocee_tx - prev_rocee_tx[$devid]))
rocee_rx_incr=$((rocee_rx - prev_rocee_rx[$devid]))
nic_tx_incr=$((nic_tx - prev_nic_tx[$devid]))
nic_rx_incr=$((nic_rx - prev_nic_rx[$devid]))
printf "| %d |" $devid
printf " ${time:11} |"
printf "%12.2f |" $(echo "scale=2; $mac_tx_incr / 1024 / 1024 / $duration" | bc)
printf "%12.2f |" $(echo "scale=2; $mac_rx_incr / 1024 / 1024 / $duration" | bc)
printf "%13.2f |" $(echo "scale=2; $rocee_tx_incr / $duration" | bc)
printf "%13.2f |" $(echo "scale=2; $rocee_rx_incr / $duration" | bc)
printf "%12.2f |" $(echo "scale=2; $nic_tx_incr / 1024 / 1024 / $duration" | bc)
printf "%12.2f |\n" $(echo "scale=2; $nic_rx_incr / 1024 / 1024 / $duration" | bc)
fi
prev_time[$devid]=$time
prev_mac_tx[$devid]=$mac_tx
prev_mac_rx[$devid]=$mac_rx
prev_rocee_tx[$devid]=$rocee_tx
prev_rocee_rx[$devid]=$rocee_rx
prev_nic_tx[$devid]=$nic_tx
prev_nic_rx[$devid]=$nic_rx
done
echo "+------------------------------------------------------------------------------------------------------+"
first_loop=0
sleep $INTERVAL
done
该脚本可直接运行使用,每隔1分钟根据MAC、RoCEE、Nic的增量计算各个指标的速率,展示效果如下:
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)