自动抓取服务器功耗

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

日常总结,一起学习进步

相关推荐
Tim风声(网络工程师)6 小时前
排查内网互联网访问流程
运维·服务器·网络
坚持就完事了7 小时前
Linux中如何添加环境变量
linux·运维·服务器
AC赳赳老秦7 小时前
政企内网落地:OpenClaw 离线环境深度适配方案,无外网场景下本地化模型对接与全功能使用
java·大数据·运维·python·自动化·deepseek·openclaw
l1t8 小时前
mingw和Linux中的gcc和llvm编译器编译的pocketpy执行同一个python脚本的不同效果
linux·运维·python
ITyunwei09878 小时前
团队管理与人才发展:如何打造一支“召之即来,来之能战”的铁军?
大数据·运维·人工智能
白緢8 小时前
一、Linux 基础入门
linux·运维·服务器
Deepoch8 小时前
面向工业现场自主运维:Deepoc 具身模型开发板的端侧智能升级路径
运维·人工智能·科技·巡检机器人·deepoc
菜菜艾9 小时前
自动化环境补丁更新系统
linux·运维·bash·运维开发
江上清风山间明月9 小时前
Nginx基于域名区分的多网站部署
运维·nginx·部署·php·多个网站
随风,奔跑9 小时前
Nginx
服务器·后端·nginx·web