自动抓取服务器功耗

以下脚本为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 ~]#

日常总结,一起学习进步

相关推荐
江湖有缘12 小时前
Docker实战 :使用Docker部署OneTerm堡垒机
运维·docker·容器
泡沫冰@12 小时前
ECS 的介绍和使用
linux·服务器·网络
姜太小白13 小时前
【Linux】df -h 卡住问题的通用排查与解决方案总结
linux·运维·php
土星云SaturnCloud13 小时前
抽水蓄能设备智慧运营:基于土星云边缘计算实现机组全生命周期预测性维护
服务器·人工智能·ai·边缘计算
fengyehongWorld13 小时前
Linux 终端快捷键
linux·运维
hyf32663314 小时前
泛程序:从零开始搭建稳定程序项目框架
运维·服务器·爬虫·百度·seo
为自己_带盐14 小时前
安敢越雷池一步?浅尝雷池WAF社区版
运维·web安全
NiceCloud喜云15 小时前
海外云服务器怎么选?适用场景、价格和避坑经验总结
运维·服务器
easy_coder15 小时前
Linux LVM 知识文档
linux·运维
小小的木头人16 小时前
Ubuntu 使用 udev + systemd + UUID 实现 USB 硬盘自动挂载
linux·运维·ubuntu