ipmitool 实时检测温度的脚本编写
生活随笔
收集整理的這篇文章主要介紹了
ipmitool 实时检测温度的脚本编写
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一般在測試服務器整機測壓過程中,需要監控固件的溫度變化,有時候會根據spec來判斷其溫度是否超標,這樣就需要我們寫一個監控溫度的腳本。
比如 我們來看一個測試用例:
測試過程檢查SDR信息固件溫度,SPEC要求各芯片低于Tjmax-10℃,spec如下:
部件 spec Tmax
FPGA 100
NIC 105
CPU0 105
DIMMG0 85
DiskG0 70
下面利用ipmitool寫一下這個測試腳本。
1 篩選的我們需要查看的固件溫度
ipmitool sdr list |egrep “FPGA|DIMM|NIC_Temp|CPU0_Temp|DiskG0_Temp”
2.這一步需要寫一個循環進行實時監控,因為整機壓測一般在48h之內,所以我們可以用for 循環來寫,每隔15秒檢測一次:
for i in {1..10000};do ipmitool sdr list |egrep "FPGA|DIMM|NIC_Temp|CPU0_Temp|DiskG0_Temp" >temp.txt sleep 15 done3.接下來我們就要判斷每個固件的溫度是否超標,先提取每個固件的溫度,然后判斷:
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.最后我們需要將判斷的結果保存到測試結果里,并記錄當前的次數和時間,用paste來實現結果的添加:
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腳本運行結果如下:
===============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總結
以上是生活随笔為你收集整理的ipmitool 实时检测温度的脚本编写的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: day 4 复习循环练习题和列表
- 下一篇: 历届试题 对局匹配-动态规划