自动抓取服务器功耗

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

脚本如下:

bash 复制代码
#!/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 ~]#

日常总结,一起学习进步

相关推荐
码农101号5 小时前
Linux中shell编程表达式和数组讲解
linux·运维·服务器
powerfulzyh5 小时前
非Root用户启动SSH服务经验小结
运维·ssh
云道轩6 小时前
升级centos 7.9内核到 5.4.x
linux·运维·centos
是小满满满满吗6 小时前
传输层:udp与tcp协议
linux·服务器·网络
爱学习的小道长6 小时前
Ubuntu Cursor升级成v1.0
linux·运维·ubuntu
EelBarb6 小时前
seafile:ubuntu搭建社区版seafile12.0
linux·运维·ubuntu
402 Payment Required6 小时前
serv00 ssh登录保活脚本-邮件通知版
运维·chrome·ssh
小柏ぁ6 小时前
calico/node is not ready: BIRD is not ready: BGP not established with xxx
运维·docker·kubernetes
Mintimate7 小时前
云服务器 Linux 手动 DD 安装第三方 Linux 发行版:原理与实战
linux·运维·服务器
RussellFans7 小时前
Linux 环境配置
linux·运维·服务器