Ipmitool
簡介
智能平臺管理接口 (IPMI) 是一種開放標(biāo)準(zhǔn)的硬件管理接口規(guī)格泡一,定義了嵌入式管理子系統(tǒng)進(jìn)行通信的特定方法。
IPMI 信息通過基板管理控制器 (BMC)(位于 IPMI 規(guī)格的硬件組件上)進(jìn)行交流您访。
使用低級硬件智能管理而不使用操作系統(tǒng)進(jìn)行管理墓律,具有兩個(gè)主要優(yōu)點(diǎn):
首先,此配置允許進(jìn)行帶外服務(wù)器管理观话;其次胃夏,操作系統(tǒng)不必負(fù)擔(dān)傳輸系統(tǒng)狀態(tài)數(shù)據(jù)的任務(wù)轴或。
command
ipmitool -I lanplus -H $bmcip -U $user -P $pass fru print 0
user
User Commands:
summary [<channel number>]
list [<channel number>]
set name <user id> <username>
set password <user id> [<password>]
disable <user id>
enable <user id>
priv <user id> <privilege level> [<channel number>]
test <user id> <16|20> [<password]>
# privilege的值定義如下:
1 callback
2 user
3 operator
4 administrator
5 OEM
最高權(quán)限
ID Name Callin Link Auth IPMI Msg Channel Priv Limit
2 root true true true ADMINISTRATOR
添加bmc用戶
#!/bin/bash
USER='USERID'
PASS='password'
CHANNEL=1
USERID=6
#對于HP的bmc,它的channel一般為2
[ dmidecode -s system-manufacturer | grep -iq 'hp' ] && CHANNEL=2
#設(shè)置id為6的賬戶名為$USER
ipmitool user set name $USERID $USER
#設(shè)置賬戶的帶外密碼
ipmitool user set password $USERID $PASS
#設(shè)置賬戶的權(quán)限為管理員權(quán)限
ipmitool user priv $USERID 4 $CHANNEL
ipmitool channel setaccess $CHANNEL $USERID callin=on ipmi=on link=on privilege=4
#設(shè)置賬戶的SOL訪問權(quán)限
ipmitool sol payload enable $CHANNEL $USERID
#啟用賬戶
ipmitool user enable $USERID
#查看所有用戶
ipmitool user list $CHANNEL
lan: bmcip
LAN Commands:
print [<channel number>]
set <channel number> <command> <parameter>
alert print <channel number> <alert destination>
alert set <channel number> <alert destination> <command> <parameter>
stats get [<channel number>]
stats clear [<channel number>]
bmc ip配置
modprobe ipmi_msghandler
modprobe ipmi_devintf
modprobe ipmi_si
ipmitool lan print 1
ipmitool lan set 1 ipsrc [ static | dhcp ]
#先改掩碼仰禀,再改網(wǎng)關(guān)
ipmitool lan set 1 netmask $mask
ipmitool lan set 1 defgw ipaddr $gateway
ipmitool lan set 1 ipaddr $bmcip
#HP需要重置iol
ipmitool mc reset cold|warm
chissis: power bootdev
Chassis Commands:
status, power, identify, policy, restart_cause, poh, bootdev, bootparam, selftest
chassis power Commands:
status, on, off, cycle, reset, diag, soft
bootdev <device> [clear-cmos=yes|no]
bootdev <device> [options=help,...]
none : Do not change boot device order
pxe : Force PXE boot
disk : Force boot from default Hard-drive
safe : Force boot from default Hard-drive, request Safe Mode
diag : Force boot from Diagnostic Partition
cdrom : Force boot from CD/DVD
bios : Force boot into BIOS Setup
floppy: Force boot from Floppy/primary removable media
示例
# 電源狀態(tài)
ipmitool -I lanplus -H 192.168.0.120 -U root -P calvin power status
# 默認(rèn)啟動項(xiàng)
ipmitool chassis bootdev disk options=persistent
fru
# 輸出全部
ipmitool fru
# 輸出ID0的信息
ipmitool fru print 0
sensor
ipmitool sensor
ipmitool sensor get 'DIMM 1'
sdr
ipmitool sdr
ipmitool sdr elist
ipmitool sdr type '0x0c'
type
Sensor Types:
Temperature (0x01) Voltage (0x02)
Current (0x03) Fan (0x04)
Physical Security (0x05) Platform Security (0x06)
Processor (0x07) Power Supply (0x08)
Power Unit (0x09) Cooling Device (0x0a)
Other (0x0b) Memory (0x0c)
Drive Slot / Bay (0x0d) POST Memory Resize (0x0e)
System Firmwares (0x0f) Event Logging Disabled (0x10)
Watchdog1 (0x11) System Event (0x12)
Critical Interrupt (0x13) Button (0x14)
Module / Board (0x15) Microcontroller (0x16)
Add-in Card (0x17) Chassis (0x18)
Chip Set (0x19) Other FRU (0x1a)
Cable / Interconnect (0x1b) Terminator (0x1c)
System Boot Initiated (0x1d) Boot Error (0x1e)
OS Boot (0x1f) OS Critical Stop (0x20)
Slot / Connector (0x21) System ACPI Power State (0x22)
Watchdog2 (0x23) Platform Alert (0x24)
Entity Presence (0x25) Monitor ASIC (0x26)
LAN (0x27) Management Subsys Health (0x28)
Battery (0x29) Session Audit (0x2a)
Version Change (0x2b) FRU State (0x2c)
獲取動環(huán)信息
# 配置
ipmitool -I lanplus -H $bmcip -U $user -P $password fru print 0
# 溫度 進(jìn)風(fēng)出風(fēng)溫度
ipmitool -I lanplus -H $bmcip -U $user -P $password sdr type Temperature
# 功率 電流
ipmitool -I lanplus -H $bmcip -U $user -P $password sdr type Current
# 電壓
ipmitool -I lanplus -H $bmcip -U $user -P $password sdr type Voltage|grep Voltage
# MEN使用率
ipmitool -I lanplus -H $bmcip -U $user -P $password sdr |grep 'MEM Usage'|awk '{print $4}'
# IO
ipmitool -I lanplus -H $bmcip -U $user -P $password sdr |grep 'IO Usage'|awk '{print $4}'
# CPU使用率
ipmitool -I lanplus -H $bmcip -U $user -P $password sdr |grep 'CPU Usage'|awk '{print $4}'
# 功率電壓電流溫度轉(zhuǎn)速
ipmitool -I lanplus -H $bmcip -U $user -P $password sdr |egrep "^Pwr|^Voltage|^Current|^Exhaust|^Inlet"
ipmitool -I lanplus -H $bmcip -U $user -P $password sdr |egrep "Watts|Volts|Amps|Exhust|Inlet"|sed "s/^/$ip\t| /g"
sel
ipmitool sel list
ipmitool sel elist
mc
MC Commands:
reset <warm|cold>
guid
info
watchdog <get|reset|off>
selftest
getenables
setenables <option=on|off> ...
recv_msg_intr Receive Message Queue Interrupt
event_msg_intr Event Message Buffer Full Interrupt
event_msg Event Message Buffer
system_event_log System Event Logging
oem0 OEM 0
oem1 OEM 1
oem2 OEM 2
getsysinfo <argument>
setsysinfo <argument> <string>
primary_os_name Primary operating system name
os_name Operating system name
system_name System Name of server(vendor dependent)
delloem_os_version Running version of operating system
delloem_url URL of BMC webserver
sol
Serial Over LAN (SOL) 功能非常有用照雁。SOL 通過 IPMI 會話重定向本地串行接口,串行控制臺答恶。
# grub開啟串口/etc/default/grub
GRUB_CMDLINE_LINUX="biosdevname=0 net.ifnames=0 console=tty0 console=ttyS0,115200"
# 運(yùn)行
ipmitool -I lanplus -H <BMCIP> -U <userid> -P <password> sol activate > ipmisol.log
IPMI SOL access configuration for Ubuntu OS
Configuring IPMI Serial-over-LAN on Debian 8 (Jessie)
ipmitool sol set enabled true 1
ipmitool sol set payload enable 1 3
tty
串行端口終端(/dev/ttySn)
串行端口終端(Serial Port Terminal)是使用計(jì)算機(jī)串行端口連接的終端設(shè)備饺蚊。計(jì)算機(jī)把每個(gè)串行端口都看作是一個(gè)字符設(shè)備。有段時(shí)間這些串行端口設(shè)備通常被稱為終端設(shè)備悬嗓,因?yàn)?那時(shí)它的最大用途就是用來連接終端污呼。這些串行端口所對應(yīng)的設(shè)備名稱是/dev/tts/0(或/dev/ttyS0), /dev/tts/1(或/dev/ttyS1)等,設(shè)備號分別是(4,0), (4,1)等包竹,分別對應(yīng)于DOS系統(tǒng)下的COM1燕酷、COM2等籍凝。若要向一個(gè)端口發(fā)送數(shù)據(jù),可以在命令行上把標(biāo)準(zhǔn)輸出重定向到這些特殊文件名上即可苗缩。
例如静浴, 在命令行提示符下鍵入:echo test > /dev/ttyS1
會把單詞”test”發(fā)送到連接在ttyS1(COM2)端口的設(shè)備上。
控制終端(/dev/tty)
如果當(dāng)前進(jìn)程有控制終端(Controlling Terminal)的話挤渐,那么/dev/tty就是當(dāng)前進(jìn)程的控制終端的設(shè)備特殊文件∷酰可以使用命令”ps –ax”來查看進(jìn)程與哪個(gè)控制終端相連浴麻。對于你登錄的shell,/dev/tty就是你使用的終端囤攀,設(shè)備號是(5,0)软免。使用命令”tty”可以查看它 具體對應(yīng)哪個(gè)實(shí)際終端設(shè)備。/dev/tty有些類似于到實(shí)際所使用終端設(shè)備的一個(gè)聯(lián)接焚挠。
控制臺終端(/dev/ttyn, /dev/console)
在Linux 系統(tǒng)中膏萧,計(jì)算機(jī)顯示器通常被稱為控制臺終端 (Console)。它仿真了類型為Linux的一種終端(TERM=Linux)蝌衔,并且有一些設(shè)備特殊文件與之相關(guān)聯(lián):tty0榛泛、tty1、tty2 等噩斟。當(dāng)你在控制臺上登錄時(shí)曹锨,使用的是tty1。使用Alt+[F1—F6]組合鍵時(shí)剃允,我們就可以切換到tty2沛简、tty3等上面去。tty1–tty6等 稱為虛擬終端斥废,而tty0則是當(dāng)前所使用虛擬終端的一個(gè)別名椒楣,系統(tǒng)所產(chǎn)生的信息會發(fā)送到該終端上(這時(shí)也叫控制臺終端)。因此不管當(dāng)前正在使用哪個(gè)虛擬終端牡肉,系統(tǒng)信息都會發(fā)送到控制臺終端上捧灰。
/dev/console即控制臺,是與操作系統(tǒng)交互的設(shè)備荚板,系統(tǒng)將一些信息直接輸出到控制臺上凤壁。目前只有在單用戶模式下,才允許用戶登錄控制臺跪另。
通過ipmitool訪問BIOS拧抖、OS
用于SOL訪問的波特率速度是易失性比特率(kbps)。它需要在BIOS中啟用串行通信重定向免绿。串行通信速度應(yīng)與波特率速度匹配唧席。
# 查看sol
ipmitool sol info 1
# 設(shè)置波特率
ipmitool sol set volatile-bit-rate <9.6/19.2/38.4/57.6/115.2>
# 打開sol
ipmitool sol activate
# 關(guān)閉sol
ipmitool sol deactivate
$ cat sol.sh
#!/bin/bash
IP=${1:-ip.lst}
IPList=`grep ^[^#] $IP`
USER='USERID'
PASS='xxx'
if [ -n "$IPList" ];then
List=( $IPList )
tmux new-window "ipmitool -H ${List[0]} -I lanplus -U $USER -P $PASS sol deactivate;ipmitool -H ${List[0]} -I lanplus -U $USER -P $PASSsol activate"
unset List[0];
fi
for i in "${List[@]}";do
tmux split-window -v "ipmitool -H $i -I lanplus -U $USER -P $PASS sol deactivate;ipmitool -H $i -I lanplus -U $USER -P $PASS sol activate"
tmux select-layout tiled 1>/dev/null
done;
tmux select-pane -t 0
tmux set-window-option synchronize-panes on
串口控制臺訪問
- 從dmesg識別BMC的串行端口,下面輸出表示 ttyS 1 適用于BMC
$ dmesg |grep tty
[ 0.000000] console [tty0] enabled
[ 1.073325] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[ 1.094732] 00:03: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[ 1.115064] 0000:00:16.3: ttyS1 at I/O 0x9080 (irq = 17) is a 16550A
- vi /etc/init/ttyS1.conf 創(chuàng)建配置文件
# ttyS1 – getty
#
#This service maintains a getty on ttyS1 from the point the system is
# started until it is shut down again.
start on stopped rc or RUNLEVEL=[2345]
stop on runlevel [!2345]
respawn
exec /sbin/getty -L 57600 ttyS1 vt102
- Ask upstart to start the getty
$ sudo start ttyS1
- Restart init
$ sudo /sbin/telinit q
- 測試
ipmitool -I lanplus -H <BMCIP> -U <userid> -P <password> sol activate
- vi /etc/default/grub 配置grub讓引導(dǎo)過程可見
# If you change this file, run ‘update-grub’ afterwards to update
# /boot/grub/grub.cfg.
GRUB_DEFAULT=0
GRUB_TIMEOUT=1
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX="console=tty0 console=ttyS1,57600n8"
# Uncomment to disable graphical terminal (grub-pc only). Unit number indicates serial communication port. COM1 – 0, COM2 – 1, COM3 – 2, etc
GRUB_TERMINAL="serial console"
GRUB_SERIAL_COMMAND="serial –speed=57600 –unit=1 –word=8 –parity=no –stop=1"
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo`
#GRUB_GFXMODE=640×480
# Uncomment if you don’t want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
7.跟新grub
upcate-grub
raw
# 查看服務(wù)器的80 Port當(dāng)前狀態(tài)
ipmitool -I lanplus -H 192.168.0.120 -U root -P calvin raw 0x30 0xB2
# 關(guān)閉iDRAC 8 電源熱備
ipmitool raw 0x30 0xCE 0 4 5 0 0 0 5 0 0 1 0
# 關(guān)閉iDRAC 電源熱備
ipmitool raw 0x30 0xCE 0 4 5 0 0 0 5 0 0 1 0 04 05 00 00 00
usage
usage: ipmitool [options...] <command>
-h This help
-V Show version information
-v Verbose (can use multiple times)
-c Display output in comma separated format
-I intf Interface to use
-H hostname Remote host name for LAN interface
-p port Remote RMCP port [default=623]
-L level Remote session privilege level [default=USER]
-A authtype Force use of authtype NONE, PASSWORD, MD2 or MD5
-U username Remote session username
-P password Remote session password
-f file Read remote session password from file
-a Prompt for remote password
-E Read password from IPMI_PASSWORD environment variable
-m address Set local IPMB address
-t address Bridge request to remote target address
Interfaces:
open Linux OpenIPMI Interface [default]
imb Intel IMB Interface
lan IPMI v1.5 LAN Interface
lanplus IPMI v2.0 RMCP+ LAN Interface
Commands:
raw Send a RAW IPMI request and print response
lan Configure LAN Channels
chassis Get chassis status and set power state
event Send pre-defined events to BMC
bmc Print BMC status and configure global enables
sdr Print Sensor Data Repository entries and readings
sensor Print detailed sensor information
fru Print built-in FRU and scan SDR for FRU locators
sel Print System Evelnt Log
sol Configure IPMIv2.0 Serial-over-LAN
user Configure BMC users
channel Configure BMC channels
session Print session information
shell Launch interactive IPMI shell
exec Run list of commands from file
set Set runtime variable for shell and exec
a) raw:發(fā)送一個(gè)原始的IPMI請求胯究,并且打印回復(fù)信息姨丈。
b) Lan:配置網(wǎng)絡(luò)(lan)信道(channel)
c) chassis :查看底盤的狀態(tài)和設(shè)置電源
d) event:向BMC發(fā)送一個(gè)已經(jīng)定義的事件(event),可用于測試配置的SNMP是否成功
e) mc: 查看MC(Management Contollor)狀態(tài)和各種允許的項(xiàng)
f) sdr:打印傳感器倉庫中的所有監(jiān)控項(xiàng)和從傳感器讀取到的值银还。
g) Sensor:打印詳細(xì)的傳感器信息徒仓。
h) Fru:打印內(nèi)建的Field Replaceable Unit (FRU)信息
i) Sel: 打印 System Event Log (SEL)
j) Pef: 設(shè)置 Platform Event Filtering (PEF)腐碱,事件過濾平臺用于在監(jiān)控系統(tǒng)發(fā)現(xiàn)有event時(shí)候,用PEF中的策略進(jìn)行事件過濾掉弛,然后看是否需要報(bào)警症见。
k) Sol/isol:用于配置通過串口的Lan進(jìn)行監(jiān)控
l) User:設(shè)置BMC中用戶的信息 。
m) Channel:設(shè)置Management Controller信道殃饿。