跳至主要内容

BMC IPMI 驗證實戰(二):各命令類別的測試重點

TL;DR:依照 IPMI 2.0 的 NetFn 分類,逐類整理命令、ipmitool 用法和測試重點。共通原則是上一篇講的:raw 與 string 雙驗證、Set → Get → 還原、負面測試、持久性,以及用實機行為和 SEL 判定結果。

BMC IPMI 驗證實戰系列

  1. 基礎觀念與通用測試方法
  2. 各命令類別的測試重點
  3. OEM 命令、韌體更新與命令速查

本系列依據公開的 IPMI v2.0 rev 1.1、DCMI v1.5 與 HPM.1 規格整理,搭配開源工具 ipmitool。內容是通用的測試思路,不針對任何特定廠商或平台;不同 BMC 韌體的實作可能不同,回傳值請以手上平台的規格為準。


1. App(NetFn 0x06)​

1.1 Device 基本資訊​

命令Cmdipmitool驗證重點
Get Device ID0x01mc infoFirmware Revision、IPMI Version(02 代表 2.0)、Manufacturer ID(3 bytes,LS byte 在前)、Product ID
Cold Reset0x02mc reset coldBMC 重啟後可重新連線;volatile 設定應回到預設值
Warm Reset0x03mc reset warm部分平台不支援,可能回 C1
Get Self Test Results0x04mc selftest55h = 無錯誤、56h = 未實作、57h = 有元件或資料損毀(第 2 byte 指出哪一項)、58h = 致命硬體錯誤
Get/Set ACPI Power State0x07 / 0x06—讀回值應與系統目前狀態(S0/S5…)一致
Get Device GUID0x08mc guid16 bytes,每次讀取結果應相同
Get System GUID0x37—應與 SMBIOS Type 1 的 UUID 一致(注意 byte order)
ipmitool raw 0x06 0x01 # Get Device ID
ipmitool raw 0x06 0x04 # Get Self Test Results → 預期 "55 00"
ipmitool raw 0x06 0x08 # Get Device GUID

1.2 Watchdog Timer​

命令Cmd說明
Reset Watchdog Timer0x22啟動或重新倒數
Set Watchdog Timer0x24只設定參數,不會啟動計時
Get Watchdog Timer0x25讀回設定和目前剩餘的倒數值

Set Watchdog Timer 的 request data:

Byte內容
1Timer Use:bit[2:0] = 1 BIOS FRB2、2 BIOS/POST、3 OS Load、4 SMS/OS、5 OEM;bit6 = don't stop;bit7 = don't log
2Timer Actions:bit[2:0] = 0 無動作、1 Hard Reset、2 Power Down、3 Power Cycle;bit[6:4] = pre-timeout interrupt
3Pre-timeout interval(秒)
4Timer Use Expiration Flags Clear(寫 1 清除對應 bit)
5–6Initial countdown,單位 100 ms,LS byte 在前
# SMS/OS、逾時後 Hard Reset、倒數 10 秒(100 × 100ms = 0x0064)
ipmitool raw 0x06 0x24 0x04 0x01 0x00 0x10 0x64 0x00
ipmitool raw 0x06 0x25 # 讀回設定
ipmitool raw 0x06 0x22 # 開始倒數
ipmitool mc watchdog get # string 版
ipmitool mc watchdog off # 測完記得關閉

測試重點:

  • Hard Reset、Power Down、Power Cycle 三種 action 都實際觸發一次,確認系統行為正確。
  • SEL 中應出現 Watchdog 2 sensor 的 event;若設了 don't log bit,則不應有紀錄。
  • Get System Restart Cause(Chassis 0x07)應回報 watchdog expiration(04h)。
  • 倒數期間持續送 Reset Watchdog,系統不應被重置。

1.3 BMC Global Enables 與 Message Flags​

命令Cmdipmitool
Set/Get BMC Global Enables0x2E / 0x2Fmc setenables / mc getenables
Clear/Get Message Flags0x30 / 0x31—

測試重點:逐一開關 System Event Logging、Event Message Buffer、Receive Message Queue 等 bit,讀回確認。關閉 SEL logging 時觸發 event,應不會寫入 SEL。

1.4 Session、Channel 與 Cipher Suite​

命令Cmdipmitool
Get Channel Authentication Capabilities0x38—
Set/Get Channel Access0x40 / 0x41channel setaccess / channel getaccess
Get Channel Info0x42channel info <ch>
Get Channel Cipher Suites0x54channel getciphers ipmi <ch>
Get Session Info0x3Dsession info all
Close Session0x3C—

Channel 編號慣例:0x0E = 目前使用的 channel、0x0F = system interface;LAN 通常是 1,但依平台而定。

測試重點:

  • 用 -C 3、-C 17 等不同 cipher suite 連線,結果應符合平台支援的清單。
  • 安全性檢查:Cipher Suite 0(不認證)應停用;IPMI 1.5 的 -I lan 若非必要也應停用。
  • 確認 session 數量上限,超過時新連線應被拒絕。

1.5 User 管理​

命令Cmdipmitool
Set/Get User Access0x43 / 0x44user priv <id> <level> <ch>
Set/Get User Name0x45 / 0x46user set name <id> <name>
Set User Password0x47user set password <id> / user test <id> 16|20

Privilege level:1 = Callback、2 = User、3 = Operator、4 = Administrator、5 = OEM。

ipmitool user list 1
ipmitool user set name 3 testuser
ipmitool user set password 3 # 互動輸入
ipmitool user priv 3 2 1 # ID 3 在 channel 1 設為 User 權限
ipmitool user enable 3

測試重點:

  • 低權限帳號執行管理命令(例如 chassis power off)應回 D4。
  • 16 bytes 與 20 bytes 密碼都要測。
  • 停用帳號後應無法登入。
  • 測完要刪除或停用測試帳號。

1.6 System Info Parameters 與 System Interface Capabilities​

  • Set/Get System Info Parameters(0x58 / 0x59):System Firmware Version、System Name、OS Name 等。可以拿 BIOS 實際版本來對照。
  • Get System Interface Capabilities(0x57):查詢 SSIF / KCS 支援的能力。

2. Chassis(NetFn 0x00)​

命令Cmdipmitool說明
Get Chassis Capabilities0x00—各 FRU/SDR/SEL device 的位址
Get Chassis Status0x01chassis statusbyte1 bit0 = power on;bit[6:5] = power restore policy
Chassis Control0x02chassis power on/off/cycle/reset/softdata:0 Power Down、1 Power Up、2 Power Cycle、3 Hard Reset、4 Diagnostic Interrupt、5 ACPI Soft Shutdown
Chassis Identify0x04chassis identify [sec|force]byte1 = 亮燈秒數;byte2 bit0 = 恆亮
Set Power Restore Policy0x06chassis policy always-on|previous|always-off0 Always Off、1 Previous、2 Always On、3 只查詢
Get System Restart Cause0x07chassis restart_cause例如 1 = Chassis Control、2 = Reset 按鈕、3 = Power 按鈕、4 = Watchdog、6/7 = AC 恢復
Set/Get System Boot Options0x08 / 0x09chassis bootdev pxe|disk|bios [options=efiboot]Parameter 5 = Boot Flags
Set Front Panel Enables0x0A—停用 Power、Reset 按鈕
Set Power Cycle Interval0x0B—Power Cycle 時斷電持續的秒數
Get POH Counter0x0Fchassis pohbyte1 = 每個 count 代表的分鐘數,後 4 bytes 為累計值
ipmitool raw 0x00 0x01 # Get Chassis Status
ipmitool raw 0x00 0x02 0x02 # Power Cycle
ipmitool raw 0x00 0x04 0x0f # Identify 亮燈 15 秒
ipmitool raw 0x00 0x06 0x03 # 只查詢目前的 restore policy

測試重點:

  • 每個電源動作都要對照實機狀態:電源 LED、風扇、螢幕輸出、chassis status 的讀值。
  • Power Restore Policy 三種設定都要實際拔插 AC 驗證。斷電後要等到電源完全放電再插回。
  • Restart Cause 要跟觸發方式對得上(命令、按鈕、Watchdog、AC 恢復)。
  • Boot Options 設定一次性開機裝置後重開,確認真的從該裝置開機,而且下一次開機會回到原本的順序(除非設定為 persistent)。
  • 停用前面板按鈕後,實際按按鈕應沒有反應;測完要恢復。

3. Sensor / Event(NetFn 0x04)​

3.1 Event​

命令Cmdipmitool
Set/Get Event Receiver0x00 / 0x01—
Platform Event Message0x02event <1|2|3> 會送出預設的測試 event
ipmitool raw 0x04 0x01 # Get Event Receiver → 通常為 "20 00"(BMC 位址 0x20、LUN 0)
ipmitool event 1 # 送一筆測試 event
ipmitool sel elist last 3 # 確認 SEL 多了一筆

3.2 Sensor​

命令Cmdipmitool
Get Sensor Reading0x2Dsensor reading "<name>"
Set/Get Sensor Threshold0x26 / 0x27sensor thresh "<name>" unc <val> / sensor get "<name>"
Set/Get Sensor Hysteresis0x24 / 0x25—
Set/Get Sensor Event Enable0x28 / 0x29—
Re-arm Sensor Events0x2A—
Get Sensor Event Status0x2B—
Get Sensor Reading Factors0x23非線性 sensor 才需要
Set/Get Sensor Type0x2E / 0x2F—

Set Sensor Threshold 的 mask byte:bit0 LNC、bit1 LC、bit2 LNR、bit3 UNC、bit4 UC、bit5 UNR。後面依序接 6 個 raw 值。raw 值需要用 SDR 中的 M、B、R exp 換算成實際單位。

測試流程範例(溫度 sensor):

  1. sensor get 記下原本的 threshold。
  2. 把 UNC 設到比目前讀值還低,人為觸發 Upper Non-Critical event。
  3. 確認 SEL 出現 assertion event、Get Sensor Event Status 對應 bit 被設起、Web UI 和 LED 狀態(若有)有變化。
  4. 把 threshold 改回來,確認出現 deassertion event。
  5. 用 mc reset cold 或手動寫回,恢復原始設定並再次確認。

3.3 PEF 與 Alerting​

命令Cmdipmitool
Get PEF Capabilities0x10pef info
Arm PEF Postpone Timer0x11—
Set/Get PEF Configuration Parameters0x12 / 0x13pef list
Set/Get Last Processed Event ID0x14 / 0x15pef status
Alert Immediate0x16—

測試重點:

  • 設定 LAN Alert Destination(LAN Config Parameter 18、19)指向測試機。觸發 event 或送 Alert Immediate 後,用 tcpdump -i <if> udp port 162 或 Wireshark 確認收到 SNMP Trap(PET)。
  • PEF action(power off、reset、alert)要實際觸發一次確認行為。
  • Postpone timer 倒數期間,PEF 不應執行 action。

4. Storage(NetFn 0x0A)​

4.1 FRU​

命令Cmdipmitool
Get FRU Inventory Area Info0x10—
Read FRU Data0x11fru print <id> / fru read <id> <file>
Write FRU Data0x12fru write <id> <file> / fru edit
ipmitool raw 0x0a 0x10 0x00 # FRU 0 大小(LS byte 在前)與存取單位
ipmitool fru read 0 fru0_backup.bin # ⚠️ 寫入前一定要先備份

測試重點:

  • 寫入測試資料後讀回比對,最後一定要寫回原始檔,避免序號、MAC 等資料遺失。
  • 寫入超出 area size 的資料,應回錯誤。
  • 修改後 fru print 解析出的欄位應正確,checksum 也要正確。

4.2 SDR Repository​

命令Cmdipmitool
Get SDR Repository Info0x20sdr info
Get SDR Repository Allocation Info0x21—
Reserve SDR Repository0x22—
Get SDR0x23sdr list / sdr elist / sdr type <type>
Add / Partial Add / Delete SDR0x24 / 0x25 / 0x26—
Clear SDR Repository0x27⚠️ 會清掉所有 sensor 定義
Get/Set SDR Repository Time0x28 / 0x29—
Run Initialization Agent0x2C—

測試重點:

  • sdr info 的 record 數量應與 sdr elist 列出的筆數一致。
  • 對 Add 或 Clear 這類破壞性操作,先 sdr dump <file> 備份;也要確認平台有辦法還原(例如重刷韌體)。
  • Run Initialization Agent 後,sensor threshold 應回到 SDR 中定義的預設值。

4.3 SEL(System Event Log)​

命令Cmdipmitool
Get SEL Info0x40sel info
Get SEL Allocation Info0x41—
Reserve SEL0x42—
Get SEL Entry0x43sel list / sel elist / sel get <id>
Add SEL Entry0x44sel add <file>
Delete SEL Entry0x46sel delete <id>
Clear SEL0x47sel clear
Get/Set SEL Time0x48 / 0x49sel time get / sel time set "<MM/DD/YYYY HH:MM:SS>"
Get/Set SEL Time UTC Offset0x5C / 0x5D—
ipmitool raw 0x0a 0x42 # Reserve SEL → 取得 Reservation ID,例如 "01 00"
ipmitool raw 0x0a 0x47 0x01 0x00 0x43 0x4c 0x52 0xaa # Clear SEL("CLR" + 0xAA 開始清除)
ipmitool raw 0x0a 0x47 0x01 0x00 0x43 0x4c 0x52 0x00 # 查詢清除進度(回 01 = 完成)

測試重點:

  • sel info 的 Entries、Free Space、Last Add Time 要隨著新增、刪除、清除正確變化;Free Space 每筆通常是 16 bytes。
  • Clear 之後通常會留下一筆「Log area reset/cleared」event。
  • Reservation ID 被其他 reserve 取代後,用舊 ID 操作應回 C5。
  • SEL 寫滿時,行為應符合平台設計(停止記錄或 overwrite),並應有對應的 event。
  • SEL Time 要跟 BMC 時間、BIOS 時間一致;UTC Offset 設定後,顯示的時間要正確。

5. Transport(NetFn 0x0C)​

5.1 LAN​

命令Cmdipmitool
Set/Get LAN Configuration Parameters0x01 / 0x02lan set <ch> ... / lan print <ch>
Suspend BMC ARPs0x03—
Get IP/UDP/RMCP Statistics0x04lan stats get <ch>

常用 parameter:3 = IP Address、4 = IP Source(1 static、2 DHCP)、5 = MAC Address、6 = Subnet Mask、12 = Default Gateway、18/19 = Alert Destination。

ipmitool raw 0x0c 0x02 0x01 0x03 0x00 0x00 # 讀 channel 1 的 IP;第一個 byte 為 parameter revision(通常為 11)
ipmitool lan print 1
ipmitool lan set 1 ipsrc static
ipmitool lan set 1 ipaddr <IP>

測試重點:

  • 用 raw 讀出的各參數,要和 lan print 的結果一致。
  • Static 與 DHCP 互相切換後,網路要能恢復連線。建議從 in-band 操作,避免把自己斷線。
  • 如果平台有 dedicated NIC 與 shared NIC,兩條路徑都要測。
  • Gratuitous ARP 的設定可以用封包擷取工具確認。

5.2 SOL(Serial over LAN)​

命令Cmdipmitool
Set/Get SOL Configuration Parameters0x21 / 0x22sol set <param> <val> <ch> / sol info <ch>
Activate / Deactivate PayloadApp 0x48 / 0x49sol activate / sol deactivate

常用 parameter:1 = SOL Enable、5 = Non-volatile Bit Rate、6 = Volatile Bit Rate(6 = 9600、7 = 19200、8 = 38400、9 = 57600、0x0A = 115200)。

ipmitool sol info 1
ipmitool sol set volatile-bit-rate 115.2 1
ipmitool sol activate # 離開:輸入 ~.

測試重點:

  • 每一種 baud rate 都要和 BIOS/OS 的 console 設定搭配,確認畫面正常、沒有亂碼。
  • SOL 停用時 activate 應失敗;已有 session 時,再開第二個應被拒絕或踢掉前一個(依平台設計)。
  • 重開機過程中,SOL 畫面應能看到 POST 與開機訊息。

6. DCMI(NetFn 0x2C,Group ID 0xDC)​

命令Cmdipmitool
Get DCMI Capabilities Info0x01dcmi discover
Get Power Reading0x02dcmi power reading
Get/Set/Activate Power Limit0x03 / 0x04 / 0x05dcmi power get_limit / set_limit / activate
Get / Set Asset Tag0x06 / 0x08dcmi asset_tag / dcmi set_asset_tag <str>
Get DCMI Sensor Info0x07dcmi sensors
Get / Set Management Controller ID String0x09 / 0x0Adcmi get_mc_id_string / dcmi set_mc_id_string <str>
Get Temperature Readings0x10dcmi get_temp_reading

測試重點:

  • 支援的功能要和 dcmi discover 宣告的一致。
  • 寫入 Asset Tag 和 MC ID 後讀回,再測超長字串的處理,最後恢復原值。
  • 溫度讀值在開機和關機狀態下都要合理,並和 sdr 的讀值互相對照。

下一篇:OEM 命令、韌體更新與命令速查。

參考資料​

  • Intelligent Platform Management Interface Specification v2.0 rev 1.1
  • Data Center Manageability Interface (DCMI) Specification v1.5
  • PICMG HPM.1 Firmware Upgrade Specification
  • man ipmitool