IPMI(Intelligent Platform Management Interface)
智能平台管理接口 (IPMI) 是一种开放标准的硬件管理接口规格,定义了嵌入式管理子系统进行通信的特定方法。IPMI 信息通过基板管理控制器 (BMC)(位于 IPMI 规格的硬件组件上)进行交流。使用低级硬件智能管理而不使用操作系统进行管理,具有两个主要优点: 首先,此配置允许进行带外服务器管理;其次,操作系统不必负担传输系统状态数据的任务。IPMI的核心是一个专用芯片/控制器(叫做服务器处理器或基板管理控制器(BMC)),其并不依赖于服务器的处理器、BIOS或操作系统来工作,可谓非常地独立,是一个单独在系统内运行的无代理管理子系统,
IPMI功能:
监控服务器的物理健康特征,如温度、电压、风扇工作状态、电源状态等;
可以通过串口、Modem以及Lan等远程环境管理服务器系统,如远程开关机;
IPMITOOL
ipmitool 是一种可用在 linux 系统下的命令行方式的 ipmi 平台管理工具,它支持 ipmi 1.5 规范(最新的规范为 ipmi 2.0),通过它可以实现获取传感器的信息、显示系统日志内容、网络远程开关机等功能。使用:
#!/usr/bin/env python
#coding:utf-8
#@author:yuanyong
#vinsion:v1.0
import subprocess
import re
import sys
import os
import threading
def IPMItool(ip,host):
p = subprocess.Popen("""ipmitool -I lanplus -H %s -U 账号 -P "密码" -L user sdr list""" %ip, stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True)
out = p.stdout.read().decode('utf-8')
p1 = subprocess.Popen("""ipmitool -I lanplus -H %s -U 账号 -P "密码" -L user power status""" %ip, stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True)
out1 = p1.stdout.read().decode('utf-8')
powerstat = out1.strip("\n").split(" ")[3]
num = r'([0-9.]+)'
rs = out.strip("\n").strip(" ").split("|")
rshash = {}
#取温度
InTemp = re.search(num,rs[1]).group()
OutTemp = re.search(num,rs[3]).group()
PCHTemp = re.search(num,rs[5]).group()
Raidtemp = re.search(num,rs[63]).group()
cputemp = re.search(num,rs[15]).group()
#去电压值
cpuv = re.search(num,rs[33]).group()
sysv1 = re.search(num,rs[27]).group()
sysv2 = re.search(num,rs[29]).group()
sysv3 = re.search(num,rs[31]).group()
#取风扇转速
fan1 = re.search(num,rs[47]).group()
fan2 = re.search(num,rs[51]).group()
fan3 = re.search(num,rs[55]).group()
fan4 = re.search(num,rs[59]).group()
#取功率值
power = re.search(num,rs[61]).group()
#将数据存入到结果hash表中
rshash["INlet_emp"] = InTemp
rshash["Outlet_temp"] = OutTemp
rshash["PCH_temp"] = PCHTemp
rshash["CPU_temp"] = cputemp
rshash["RAID_temp"] = Raidtemp
rshash["Sys_3.3v"] = sysv1
rshash["Sys_5v"] = sysv2
rshash["Sys_12v"] = sysv3
rshash["CPU_volt"] = cpuv
rshash["System_fan1"] = fan1
rshash["System_fan2"] = fan2
rshash["System_fan3"] = fan3
rshash["System_fan4"] = fan4
rshash["Sys_power"] = power
rshash["power_status"] = powerstat
#将结果用sender发送给zabbix-server
for item in rshash:
rslag = "/node3/zabbix-3.2.4/bin/zabbix_sender -z zabbix_server的ip -s %s -k %s -o %s" %(host,item,rshash[item])
print rslag
os.system(rslag)
if __name__=='__main__':
threadlist = []
with open("../conf/hostip.csv",'r') as f:
for line in f.readlines():
host,ip = line.strip("\n").strip("\t").split(",")
print line.strip("\n").strip("\t").split(",")
print host,ip
host = str(host.strip("\r"))
ip = str(ip.strip("\r"))
t = threading.Thread(target=IPMItool,args=(ip,host))
threadlist.append(t)
for threaditem in threadlist:
threaditem.start()
for threaditem in threadlist:
threaditem.join()
网友评论