ipmitool 是一种可用在 linux 系统下的命令行方式的 ipmi 平台管理工具,它支持 ipmi 1.5 规范(最新的规范为 ipmi 2.0),通过它可以实现获取感测器的信息、显示系统日誌内容、网路远程开关机等功能。
基本介绍
ipmitool 是一种可用在 linux 系统下的命令行方式的 ipmi 平台管理工具,它支持 ipmi 1.5 规范(最新的规范为 ipmi 2.0),通过它可以实现获取感测器的信息、显示系统日誌内容、网路远程开关机等功能。
特点
IPMI(Intelligent Platform Management Interface)即智慧型平台管理接口是使硬体管理具备“智慧型化”的新一代通用接口标準。用户可以利用 IPMI 监视伺服器的物理特徵,如温度、电压、电扇工作状态、电源供应以及机箱入侵等。Ipmi 最大的优势在于它是独立于 CPU BIOS 和 OS 的,所以用户无论在开机还是关机的状态下,只要接通电源就可以实现对伺服器的监控。Ipmi 是一种规范的标準,其中最重要的物理部件就是BMC(Baseboard Management Controller 如图1),一种嵌入式管理微控制器,它相当于整个平台管理的“大脑”,通过它 ipmi 可以监控各个感测器的数据并记录各种事件的日誌。
命令
一般命令
raw #传送一个原始的IPMI请求,并且列印回覆信息。
Lan #配置网路(lan)信道(channel)
chassis #查看底盘的状态和设定电源
event #向BMC传送一个已经定义的事件(event),可用于测试配置的SNMP是否成功
mc #查看MC(Management Contollor)状态和各种允许的项
sdr #列印感测器仓库中的所有监控项和从感测器读取到的值。
Sensor #列印详细的感测器信息。
Fru #列印内建的Field Replaceable Unit (FRU)信息
Sel #列印 System Event Log (SEL)
Pef #设定 Platform Event Filtering (PEF),事件过滤平台用于在监控系统发现有event时候,用PEF中的策略进行事件过滤,然后看是否需要报警。
Sol/isol #用于配置通过串口的Lan进行监控
User #设定BMC中用户的信息 。
Channel #设定Management Controller信道。
Ipmitool –I open sensor list #命令可以获取感测器中的各种监测值和该值的监测阈值,包括(CPU温度,电压,风扇转速,电源调製模组温度,电源电压等信息)
Ipmitool –I open sensor get “CPU0Temp” #可以获取ID为CPU0Temp监测值,CPU0Temp是sensor的ID,伺服器不同,ID表示也不同。
Ipmitool –I open sensor thresh #设定ID值等于id的监测项的各种限制值。
Ipmitool –I open chassis status #查看底盘状态,其中包括了底盘电源信息,底盘工作状态等
Ipmitool –I open chassis restart_cause #查看上次系统重启的原因
Ipmitool –I open chassis policy list #查看支持的底盘电源相关策略。
Ipmitool –I open chassis power on #启动底盘,用此命令可以远程开机
Ipmitool –I open chassis power off #关闭底盘,用此命令可以远程关机
Ipmitool –I open chassis power reset #实现硬重启,用此命令可以远程重启
#Ipmi还可以设定系统启动boot的设备,具体见ipmitool帮助文档
Ipmitool –I open mc reset #使BMC重新硬启动
Ipmitool –I open mc info #查看BMC硬体信息
Ipmitool –I open mc getenables #列出BMC所有允许的选项
Ipmitool –I open mc setenables =[on|off] #设定bmc相应的允许/禁止选项。
Ipmitool-I open event 1 #传送一个温度过高的讯息到System Event Log中,可以传送的Event有:
Temperature: Upper Critical: Going High
Voltage Threshold: Lower Critical: Going Low
Memory: Correctable ECC Error Detected
Ipmitool-I open event #命令可以用测试配置的IPMI中的snmp功能是否成功。
Ipmitool -I open lan print 1 #列印现咱channel 1的信息 。
Ipmitool -I open lan set 1 ipaddr 10.10.113.95 #设定channel 1的IP位址为10.10.113.95
Ipmitool -I open lan set 1 snmp public #设定channel 1 上snmp的community为public。
Ipmitool -I open lan set 1 access on #设定channel 1允许访问。
Ipmitool -I open pef info #列印Platform Event Filtering (pef)信息
Ipmitool -I open pef status #查看Platform Event Filtering (pef)状态
Ipmitool -I open pef policy #查看Platform Event Filtering (pef)策略设定
Ipmitool -I open sdr list fru #读取fru信息并显示。
ipmitool sel clear #清除记录
ipmitool sel elist
ipmitool sel list
ipmitool fru
ipmitool fru print #显示fru信息
ipmitool fru print 0
ipmitool fru print 1
ipmitool bmc reset cold #重启bmc
ipmitool sdr #查看psu fan (BAT)等信息
ipmitool sdr type fan
ipmitool mc info #查看bmc信息
ipmitool lan print #显示lan信息
ipmitool lan print|egrep "MAC Address" #得到bmc的oui
ipmitool lan set 1 ipsrc dhcp #设定动态ip 1用户
ipmitool -H $bmc_ip -U admin -P admin mc info #设定用户名密码
ipmitool chassis policy always-off
ipmitool chassis identify force
ipmitool chassis identify off
ipmitool sdr type Temperature
ipmitool sol payload enable 1
IPMI RAW command
参照IPMI spec 2.0 with KCS
BMC 可以控制的功能很多, 除了常用的ipmi command, 其余还有许多,可以依靠RAW command 来与BMC 沟通完成, 并且有"隐藏"的command 可以用,尤其是OEM command, 可以询问各机种BMC RD
以下整理出来较有用的command, 需注意Data 的Request/Response 起始位置。
Request 指令格式 "ipmitool raw NetFnCode CommandCode Data .."
Ex.ipmitool raw 0x0C 0x02 0x01 0x04 0x00 0x00(Get BMC IP Source)
0x0C Request Transport Media-specific configuration & control
0x02 GET LAN Config
0x01 Channel Num
0x04 IP Source(Selector)
0x00 not use set Selector
0x00 not require block num
Response 指令格式 "NetFnCode CommandCode CopmpletionCode Data .."
Ex.0x0D 0x02 0x00 0x01
0x0D Response Transport Media-specific configuration & control
0x02 GET LAN Config
0x00 Command Completed Successful
0x01 IP source is Static
## NetFn code
0x00(request), 0x01(Response) Chassis
0x02(request), 0x03(Response) Bridge
0x04(request), 0x05(Response) Sensor/Event
0x06(request), 0x07(Response) Application
0x08(request), 0x09(Response) Firmware Transfer
0x0A(request), 0x0B(Response) Non-volatile storage
0x0C(request), 0x0D(Response) Transport Media-specific configuration & control
0x0E- 0x2B Reserved
2Ch-2Dh Extension Non-IPMI group
2Eh-2Fh OEM/Non-IPMI group
30h-3Fh Controllerspecific OEM/Group
## Completion Code
0x00 Command Completed Normally
0xC0 Node Busy
0xC1 Invalid Command
0xC2 Command invalid for given NetFn
0xC3 Timeout
0xC4 Storage Out of space
0xC5 Reservation Canceled or Invalid Reservation ID
0xC6 Request data truncated
0xC7 Request data length invalid
0xC8 Request data field length limit exceeded
0xC9 Parameter/Data out of range
0xCA Cannot return number of requested data bytes
0xCB Requested Sensor, data, or record not present
0xCC Invalid data field in Request
0xCD Command illegal for specified sensor or record type
0xCE Command response could not be provided
0xCF Cannot execute duplicated request
0xD0 Command response could not be provided. SDR Repository in update mode.
0xD1 Command response could not be provided. Device in firmware update mode.
0xD2 Command response could not be provided. BMC initialization or
initializationagent in progress
0xD3 Destination unavailable
0xD4 Cannot execute command due to insufficient privilege level or other
securitybased restriction
0xD5 Cannot execute command. Command or parameter not supported in present
state
0xD6 Cannot execute command. Parameter is illegal
0xFF Unspecified error
0x01-0x7E OEM completion codes
0x80-0xBE Standard command-specific codes
0x7F, 0xBF, 0xD7-0xFE Reserved
