以下脚本为linux系统内通过ipmitool工具自动抓取服务器当前功耗,每隔5分钟抓取一次,累计抓取20次

脚本如下:

#!/bin/bash

current_dir=`pwd`
node_list=${current_dir}/nodelistbmc      #BMC IP
username=Administrator                   #BMC用户
password=Admin@9000                      #BMC用户密码
sum=20									 #抓取次数

readarray -t ip_address < ${node_list}
count=${#ip_address[@]}

echo -e "\n>>> Start to grab power consumption>>>"
echo -e "--------------------------------------------------------------------------"
while (($sum>0));
do
   for (( i=0; i<$count; i++ ))
   do
      echo -e "\n>>> This is the $ith time of grabbing "
      echo -n ${ip_address[$i]}, >> ${current_dir}/consumption.log
      ipmitool -H ${ip_address[$i]}  -I lanplus -U ${username} -P ${password} sdr elist | awk -F"|" '/^Power  /{print $5}'  >> ${current_dir}/consumption.log

   done
sum=`expr $sum - 1`
sleep 300            #每隔5分钟抓取一次
done

echo -e "--------------------------------------------------------------------------"
echo -e "\n>>>Grabbing finished>>>"
[root@linux ~]#


日常总结,一起学习进步

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐