ipmitool 实时检测温度的脚本编写
一般在測(cè)試服務(wù)器整機(jī)測(cè)壓過(guò)程中,需要監(jiān)控固件的溫度變化,有時(shí)候會(huì)根據(jù)spec來(lái)判斷其溫度是否超標(biāo),這樣就需要我們寫(xiě)一個(gè)監(jiān)控溫度的腳本。
比如 我們來(lái)看一個(gè)測(cè)試用例:
測(cè)試過(guò)程檢查SDR信息固件溫度,SPEC要求各芯片低于Tjmax-10℃,spec如下:
部件 spec Tmax
FPGA 100
NIC 105
CPU0 105
DIMMG0 85
DiskG0 70
下面利用ipmitool寫(xiě)一下這個(gè)測(cè)試腳本。
1 篩選的我們需要查看的固件溫度
ipmitool sdr list |egrep “FPGA|DIMM|NIC_Temp|CPU0_Temp|DiskG0_Temp”
2.這一步需要寫(xiě)一個(gè)循環(huán)進(jìn)行實(shí)時(shí)監(jiān)控,因?yàn)檎麢C(jī)壓測(cè)一般在48h之內(nèi),所以我們可以用for 循環(huán)來(lái)寫(xiě),每隔15秒檢測(cè)一次:
for i in {1..10000};do ipmitool sdr list |egrep "FPGA|DIMM|NIC_Temp|CPU0_Temp|DiskG0_Temp" >temp.txt sleep 15 done3.接下來(lái)我們就要判斷每個(gè)固件的溫度是否超標(biāo),先提取每個(gè)固件的溫度,然后判斷:
temp=`cat temp.txt|awk '{print $3}'` fpga=`cat temp.txt|grep -i fpga|awk '{print $3}'` nic=`cat temp.txt|grep -i nic|awk '{print $3}'` cpu=`cat temp.txt|grep -i cpu|awk '{print $3}'` dimm=`cat temp.txt|grep -i dimm|awk '{print $3}'` disk=`cat temp.txt|grep -i disk|awk '{print $3}'` if [ $fpga -lt 90 ];thenecho "pass" >>result.txtelseecho "failed" >>result.txt fi if [ $nic -lt 105 ];thenecho "pass" >>result.txtelseecho "failed" >>result.txt fi if [ $cpu -lt 95 ];thenecho "pass" >>result.txtelseecho "failed" >>result.txt fi if [ $dimm -lt 75 ];thenecho "pass" >>result.txtelseecho "failed" >>result.txt fi if [ $disk -lt 60 ];thenecho "pass" >>result.txtelseecho "failed" >>result.txt fi4.最后我們需要將判斷的結(jié)果保存到測(cè)試結(jié)果里,并記錄當(dāng)前的次數(shù)和時(shí)間,用paste來(lái)實(shí)現(xiàn)結(jié)果的添加:
echo "===============$i==============="|tee -a temp_result.txt date |tee -a temp_result.txt paste temp.txt result.txt |tee -a temp_result.txt5.完整版腳本如下:
#!/bin/bash rm -rf result.txt rm -rf temp_result.txt for i in {1..10000};do ipmitool sdr list |egrep "FPGA|DIMM|NIC_Temp|CPU0_Temp|DiskG0_Temp" >temp.txt temp=`cat temp.txt|awk '{print $3}'` fpga=`cat temp.txt|grep -i fpga|awk '{print $3}'` nic=`cat temp.txt|grep -i nic|awk '{print $3}'` cpu=`cat temp.txt|grep -i cpu|awk '{print $3}'` dimm=`cat temp.txt|grep -i dimm|awk '{print $3}'` disk=`cat temp.txt|grep -i disk|awk '{print $3}'` if [ $fpga -lt 90 ];thenecho "pass" >>result.txtelseecho "failed" >>result.txt fi if [ $nic -lt 105 ];thenecho "pass" >>result.txtelseecho "failed" >>result.txt fi if [ $cpu -lt 95 ];thenecho "pass" >>result.txtelseecho "failed" >>result.txt fi if [ $dimm -lt 75 ];thenecho "pass" >>result.txtelseecho "failed" >>result.txt fi if [ $disk -lt 60 ];thenecho "pass" >>result.txtelseecho "failed" >>result.txt fi echo "===============$i==============="|tee -a temp_result.txt date |tee -a temp_result.txt paste temp.txt result.txt |tee -a temp_result.txt rm -rf result.txt sleep 15 done腳本運(yùn)行結(jié)果如下:
===============1=============== Wed Sep 29 02:17:43 CST 2021 FPGA_Temp | 79 degrees C | ok pass NIC_Temp | 87 degrees C | ok pass CPU0_Temp | 78 degrees C | ok pass DIMMG0_Temp | 56 degrees C | ok pass DiskG0_Temp | 46 degrees C | ok pass ===============2=============== Wed Sep 29 02:18:01 CST 2021 FPGA_Temp | 79 degrees C | ok pass NIC_Temp | 87 degrees C | ok pass CPU0_Temp | 79 degrees C | ok pass DIMMG0_Temp | 56 degrees C | ok pass DiskG0_Temp | 46 degrees C | ok pass ===============3=============== Wed Sep 29 02:18:18 CST 2021 FPGA_Temp | 79 degrees C | ok pass NIC_Temp | 87 degrees C | ok pass CPU0_Temp | 79 degrees C | ok pass DIMMG0_Temp | 56 degrees C | ok pass DiskG0_Temp | 47 degrees C | ok pass總結(jié)
以上是生活随笔為你收集整理的ipmitool 实时检测温度的脚本编写的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: day 4 复习循环练习题和列表
- 下一篇: 历届试题 对局匹配-动态规划