IPMI的幾個問題


IPMI針對大量監控、控制和自動回復服務器的作業,提供了智能型的管理方式。此標准適用於不同的服務器拓朴學,以及Windows、Linux、 Solaris、Mac或是混合型的操作系統。此外,由於IPMI可在不同的屬性值下運作,即使服務器本身的運作不正常,或是由於任何原因而無法提供服務,IPMI仍可正常運作。

IPMI的核心是一個專用芯片/控制器(叫做服務器處理器或基板管理控制器(BMC)),其並不依賴於服務器的處理器、BIOS或操作系統來工作,可謂非常地獨立,是一個單獨在系統內運行的無代理管理子系統,只要有BMC與IPMI固件其便可開始工作,而BMC通常是一個安裝在服務器主板上的獨立的板卡,現在也有服務器主板提供對IPMI支持的。IPMI良好的自治特性便克服了以往基於操作系統的管理方式所受的限制,例如操作系統不響應或未加載的情況下其仍然可以進行開關機、信息提取等操作。

在工作時,所有的IPMI功能都是向BMC發送命令來完成的,命令使用IPMI規范中規定的指令,BMC接收並在系統事件日志中記錄事件消息,維護描述系統中傳感器情況的傳感器數據記錄。在需要遠程訪問系統時,IPMI新的LAN上串行(SOL)特性很有用。SOL改變IPMI會話過程中本地串口傳送方向,從而提供對緊急管理服務、Windows專用管理控制台或Linux串行控制台的遠程訪問。BMC通過在LAN上改變傳送給串行端口的信息的方向來做到這點,提供了一種與廠商無關的遠程查看啟動、操作系統加載器或緊急管理控制台來診斷和維修故障的標准方式。

當需要對系統文本控制台進行遠程訪問時,Serial Over LAN (SOL) 功能將非常有用。SOL 通過 IPMI 會話重定向本地串行接口,允許遠程訪問Windows 的緊急事件管理控制台 (EMS) 特殊管理控制台 (SAC),或訪問 LINUX 串行控制台。這個過程的步驟是 IPMI固件截取數據,然后通過局域網重新發送定向到串行端口的信息。 這就提供了遠程查看BOOT、OS 加載器或緊急事件管理控制台以診斷並修復服務器相關問題的標准方法,而無需考慮供應商。它允許在引導階段配置各種組件。

而在命令傳輸的安全性方面,用戶也無需擔心,IPMI增強的認證(基於安全哈希算法1和基於密鑰哈希消息認證)和加密(高級加密標准和Arcfour)功能有助於實現安全的遠程操作。對VLAN的支持更是為設置管理專用網絡提供了方便,並且可以以通道為基礎進行配置。

IPMI協議被廣泛用於服務器監控中,包括采集CPU溫度、風扇轉速、主板溫度,以及遠程開關機等等。而且IPMI獨立於硬件和操作系統,無論是CPU、BIOS,還是OS出現故障,都不會影響IPMI的工作。因為IPMI的硬件設備BMC(Baseboard Management Controller)是一個獨立的板卡,獨立供電。

使用IPMI監控服務器主要有兩種模式:本地和遠程。

本地監控:

需要安裝:

  • IPMI驅動(硬件設備被操作系統識別)
  • ipmitool或其他工具(通過驅動獲取服務器信息)

遠程監控:

只需要在客戶端安裝ipmitool或其他工具 
遠程模式下,IPMI使用RMCP,RMCP基於UDP協議實現。 
遠程監控也就是基於UDP的網絡通信。 
服務器IPMI使用的端口一般是623.

下面介紹ipmitool的使用

ipmitool的使用

基本的幫助信息可以通過-h選項獲取 
也可以使用man ipmitool

$ ipmitool -h
ipmitool version 1.8.11 usage: ipmitool [options...] <command> -h This help -V Show version information -v Verbose (can use multiple times) -c Display output in comma separated format -d N Specify a /dev/ipmiN device to use (default=0) -I intf Interface to use -H hostname Remote host name for LAN interface -p port Remote RMCP port [default=623] -U username Remote session username -f file Read remote session password from file -z size Change Size of Communication Channel (OEM) -S sdr Use local file for remote SDR cache -D tty:b[:s] Specify the serial device, baud rate to use and, optionally, specify that interface is the system one -a Prompt for remote password -Y Prompt for the Kg key for IPMIv2 authentication -e char Set SOL escape character -C ciphersuite Cipher suite to be used by lanplus interface -k key Use Kg key for IPMIv2 authentication -y hex_key Use hexadecimal-encoded Kg key for IPMIv2 authentication -L level Remote session privilege level [default=ADMINISTRATOR] Append a '+' to use name/privilege lookup in RAKP1 -A authtype Force use of auth type NONE, PASSWORD, MD2, MD5 or OEM -P password Remote session password -E Read password from IPMI_PASSWORD environment variable -K Read kgkey from IPMI_KGKEY environment variable -m address Set local IPMB address -b channel Set destination channel for bridged request -t address Bridge request to remote target address -B channel Set transit channel for bridged request (dual bridge) -T address Set transit address for bridge request (dual bridge) -l lun Set destination lun for raw commands -o oemtype Setup for OEM (use 'list' to see available OEM types) -O seloem Use file for OEM SEL event descriptions -N seconds Specify timeout for lan [default=2] / lanplus [default=1] interface -R retry Set the number of retries for lan/lanplus interface [default=4] Interfaces: open Linux OpenIPMI Interface [default] imb Intel IMB Interface lan IPMI v1.5 LAN Interface lanplus IPMI v2.0 RMCP+ LAN Interface serial-terminal Serial Interface, Terminal Mode serial-basic Serial Interface, Basic Mode Commands: raw Send a RAW IPMI request and print response i2c Send an I2C Master Write-Read command and print response spd Print SPD info from remote I2C device lan Configure LAN Channels chassis Get chassis status and set power state power Shortcut to chassis power commands event Send pre-defined events to MC mc Management Controller status and 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 gendev Read/Write Device associated with Generic Device locators sdr sel Print System Event Log (SEL) pef Configure Platform Event Filtering (PEF) sol Configure and connect IPMIv2.0 Serial-over-LAN tsol Configure and connect with Tyan IPMIv1.5 Serial-over-LAN isol Configure IPMIv1.5 Serial-over-LAN user Configure Management Controller users channel Configure Management Controller channels session Print session information dcmi Data Center Management Interface sunoem OEM Commands for Sun servers kontronoem OEM Commands for Kontron devices picmg Run a PICMG/ATCA extended cmd fwum Update IPMC using Kontron OEM Firmware Update Manager firewall Configure Firmware Firewall delloem OEM Commands for Dell systems shell Launch interactive IPMI shell exec Run list of commands from file set Set runtime variable for shell and exec hpm Update HPM components using PICMG HPM.1 file ekanalyzer run FRU-Ekeying analyzer using FRU files ime Update Intel Manageability Engine Firmware 

下面就幾個常用的選項做說明。

設置用戶

首先查看用戶列表

# ipmitool user list 1 ID Name Callin Link Auth  IPMI Msg Channel Priv Limit 2 root true true true ADMINISTRATOR 
  • # ipmitool user set 
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]> 
  • 例如 

user id使用3

#設置用戶 # ipmitool user set name 3 test # ipmitool user set password 3 test 
  • 設置用戶權限

channel 為1,user ID為3,privilege為4

privilege的值定義如下;

1 callback 
2 user 
3 operator 
4 administrator 
5 OEM

設置用戶權限
# ipmitool channel setaccess 1 3 callin=on ipmi=on link=on privilege=4 

查看權限

# ipmitool channel getaccess 1 3
  • 1

再次查看用戶列表

# ipmitool user list 1 ID Name Callin Link Auth  IPMI Msg Channel Priv Limit 2 root true true true ADMINISTRATOR 3 test true true true ADMINISTRATOR 

配置網絡

配置IP、網關、子網掩碼 
這個地方配置的IP沒有什么限制,只要不與其他機器IP沖突,符合IP規則即可。

#ipmitool lan set 1 ipaddr *.*.*.* #ipmitool lan set 1 netmask *.*.*.* #ipmitool lan set 1 defgw ipaddr *.*.*.* #ipmitool lan set 1 access on

查看網絡配置

#ipmitool lan print 1
  • 1

interface的使用

-I interface

  • open
  • lan
  • lanplus
  • 其他

如果沒有-I選項,ipmitool默認使用open,即Linux OpenIPMI

lanplus是lan的增強版 
lan及lanplus主要用於遠程監控

獲取傳感器數據

傳感器簡潔數據 
左邊第一列是Sensor ID,第二列是Sensor Readings

#ipmitool sdr list Temp | 27 degrees C | ok Temp | 50 degrees C | ok Temp | 38 degrees C | ok Temp | 39 degrees C | ok Ambient Temp | 26 degrees C | ok Ambient Temp | 30 degrees C | ok IOB Temp | 40 degrees C | ok Ambient Temp | 23 degrees C | ok Planar Temp | 30 degrees C | ok Temp | 26 degrees C | ok Temp | disabled | ns

傳感器詳細數據

#ipmitool -v sdr list
Sensor ID              : Temp (0x1) Entity ID : 3.1 (Processor) Sensor Type (Analog) : Temperature Sensor Reading : 27 (+/- 1) degrees C Status : ok Nominal Reading : 50.000 Normal Minimum : 11.000 Normal Maximum : 69.000 Positive Hysteresis : 1.000 Negative Hysteresis : 1.000 Minimum sensor range : Unspecified Maximum sensor range : Unspecified Event Message Control : No Events From Sensor Readable Thresholds : Thresholds Fixed Settable Thresholds : Thresholds Fixed Event Status : Event Messages Disabled Assertion Events : Event Enable : Event Messages Disabled Assertions Enabled : Sensor ID : Temp (0x2) Entity ID : 3.2 (Processor) Sensor Type (Analog) : Temperature Sensor Reading : 50 (+/- 1) degrees C Status : ok Nominal Reading : 50.000 Normal Minimum : 11.000 Normal Maximum : 69.000 Positive Hysteresis : 1.000 Negative Hysteresis : 1.000 Minimum sensor range : Unspecified Maximum sensor range : Unspecified Event Message Control : No Events From Sensor Readable Thresholds : Thresholds Fixed Settable Thresholds : Thresholds Fixed Event Status : Event Messages Disabled Assertion Events : Event Enable : Event Messages Disabled Assertions Enabled : 。。。

可以看到sensor ID是重復的,如何區分是哪個硬件模塊的數據呢? 
如果使用

#ipmitool sdr get "Temp"
  • 1

只能獲取到第一個Sensor ID的數據。

上面可以看到,有一個entity id,它是唯一的。

例如CPU1的entity id 為3.1,可以列出CPU1所有數據

# ipmitool sdr entity 3.1 Temp | 01h | ok | 3.1 | 34 degrees C VCORE | 12h | ok | 3.1 | State Deasserted 2.5V VDDA PG | 14h | ok | 3.1 | State Deasserted 1.2V VDDR PG | 16h | ok | 3.1 | State Deasserted Presence | 50h | ok | 3.1 | Present Status | 60h | ok | 3.1 | Presence detected CPU1 | 00h | ns | 3.1 | Physical FRU @B0h 

采用entity id + sensor id 就可以唯一確定一個數據

# ipmitool sdr entity 3.1 | grep "Temp" Temp | 01h | ok | 3.1 | 34 degrees C

遠程監控一例

獲取遠程主機10.10.228.118的傳感器列表,端口623,用戶為test,密碼為test

#ipmitool -I lanplus -H 10.10.228.118 -p 623 -U test -P "test" sdr list
  • 1

system event log

打印系統事件log

#ipmitool sel list 
  • 1

輸出:

1 | 07/31/2013 | 12:36:31 | Power Supply #0x62 | Power Supply AC lost | Asserted ...

如何找到幫助信息

以command sdr為例

#ipmitool sdr help
SDR Commands:  list | elist [all|full|compact|event|mcloc|fru|generic] all All SDR Records full Full Sensor Record compact Compact Sensor Record event Event-Only Sensor Record mcloc Management Controller Locator Record fru FRU Locator Record generic Generic Device Locator Record type [sensor type] list Get a list of available sensor types get Retrieve the state of a specified sensor info Display information about the repository itself entity <id>[.<instance>] Display all sensors associated with an entity dump <file> Dump raw SDR data to a file fill sensors Creates the SDR repository for the current configuration file <file> Load SDR repository from a file 

如何查看entity有哪些

$ ipmitool sdr entity

Entity IDs:

     0 Unspecified 1 Other 2 Unknown 3 Processor 4 Disk or Disk Bay 5 Peripheral Bay 6 System Management Module 7 System Board 8 Memory Module 9 Processor Module 10 Power Supply 11 Add-in Card 12 Front Panel Board 13 Back Panel Board 14 Power System Board 15 Drive Backplane 16 System Internal Expansion Board 17 Other System Board 18 Processor Board 19 Power Unit 20 Power Module 21 Power Management 22 Chassis Back Panel Board 23 System Chassis 24 Sub-Chassis 25 Other Chassis Board 26 Disk Drive Bay 27 Peripheral Bay 28 Device Bay 29 Fan Device 30 Cooling Unit 31 Cable/Interconnect 32 Memory Device 33 System Management Software 34 BIOS 35 Operating System 

查看BMC信息

# ipmitool mc info Device ID : 32 Device Revision : 0 Firmware Revision : 1.85 IPMI Version : 2.0 Manufacturer ID : 674 Manufacturer Name : DELL Inc 。。。

問題

問題1

# ipmitool -I lan -H 10.61.*.* -U root -P "root" sdr Authentication type NONE not supported Authentication type NONE not supported Error: Unable to establish LAN session Get Device ID command failed Unable to open SDR for reading
  • 解決: 

使用 –I lanplus 

# ipmitool -I lanplus -H 10.61.*.* -U root -P "root" sdr

問題2

# ipmitool -I lanplus -H 10.61.*.* -U test -P "test" sdr -v RAKP 2 message indicates an error : unauthorized name Error: Unable to establish IPMI v2 / RMCP+ session Get Device ID command failed Unable to open SDR for reading
  • 原因: 

密碼錯誤

問題3

設置權限

# ipmitool channel setaccess 1 7 callin=on ipmi=on link=on privilege=user Set User Access (channel 1 id 7) failed: Invalid data field in request 
  • 原因: 

選項privilege 只支持數字形式

改為

# ipmitool channel setaccess 1 7 callin=on ipmi=on link=on privilege=2
  • 1

下面這個也會出現同樣的問題

# ipmitool user priv 7 admin


一般來說,BMC具有以下功能:

1.通過系統的串行端口進行訪問

2. 故障日志記錄和 SNMP 警報發送

3.訪問系統事件日志 (System Event Log ,SEL) 和傳感器狀況

4.控制包括開機和關機

5.獨立於系統電源或工作狀態的支持

6.用於系統設置、基於文本公用程序操作系統控制台的文本控制台重定向

而通過IPMI ,用戶可以主動監測組件的狀況,以確保不超出預置閾值,例如服務器溫度。這樣,通過避免不定期的斷電,協助維護了 IT 資源的運行時間。 IPMI的預告故障能力也有助於 IT 周期的管理。通過檢查系統事件日志 (SEL),可以更輕松的預先判定故障組件。

 

    使用 ipmi 的必要條件——必須在硬件、OS、管理工具等幾個方面都滿足:

         1.服務器硬件本身提供對 ipmi 的支持 (硬件)
         目前惠普、戴爾和 NEC 等大多數廠商的服務器都支持 IPMI 2.0,但並不是所有服務器都支持,所以應該先通過產品手冊或在 BIOS 中確定服務器是否支持 ipmi,也就是說服務器在主板上要具有 BMC 等嵌入式的管理微控制器。

         這里拿DELL R710為例:

         1) 啟動服務器 使用ctrl+e 進去ipmi server mangement configuration

         2)設置IPMI Over LAN 為On

          

          3)進入IPMI Parameters 設置服務器ip/子網掩碼 (也可以進去系統通過Ipmitool管理軟件設置)

           

          4)進入LAN User Confuguration 設置用戶名 密碼 (同樣也可以進去系統通過Ipmitool管理軟件設置)

         

         

         2.操作系統提供相應的 ipmi 驅動  (OS)
         通過操作系統監控服務器自身的 ipmi 信息時需要系統內核提供相應的支持,linux 系統通過內核對 OpenIPMI(ipmi 驅動)的支持來提供對 ipmi 的系統接口。在使用驅動之前,請先啟動該驅動:
          service ipmi start
          或者啟動模塊:
          modprobe ipmi_msghandler
          modprobe ipmi_devintf
          modprobe ipmi_si
          modprobe ipmi_poweroff
          modprobe ipmi_watchdog

          3.ipmi 管理工具 (管理工具)
          Linux 下的命令行方式的 ipmi 平台管理工具 ipmitool。
          ipmitool 命令需要通過相應的interface來訪問BMC,在本地獲取信息時候采用的是-I open,即為OpenIPMI接口,IPMItool命令包含的接口有open、lan、lanplus。其中open是指的是OpenIPMI與 BMC通信,Lan是通過Ethernet LAN網用IPV4的udp協議與BMC通信。UDP的數據段包含了IPMI request/resoponse消息,消息具有一個IPMI session 頭和RMCP 頭。
          IPMI使用Remote Management Control Protocol (RMCP) 版本1支持操作系統關閉(pre-OS和OS-absent),RMCP把把數據發送到UDP的623端口。象lan接口一樣,lanplus同樣使用 Ethernet LAN 的UDP協議與BMC通信,但是lanplus使用RMCP+協議(在IPMIV20中描述)來同新,RMCP+允許使用改經的認證方式和數據完整性檢查。Open端口用於本地監控系統使用的;Lan/lanplus通過網絡進行遠程監控。

 

         利用ipmitool實現對Linux服務器的ipmi管理有2種方式:

          1)通過OS監控本地服務,實現對本地服務器的管理。

           架構:應用軟件ipmitool <----------->OS提供支持ipmi系統接口<------------>硬件主板上有bmc芯片

          通過ipmitool命令獲取獲取傳感器中的各種監測值和該值的監測閾值,包括(CPU溫度,電壓,風扇轉速,電源調制模塊溫度,電源電壓等信息)

          ipmitool本地監控使用命令:ipmitool -I open command,其中-I open表示使用OpenIPMI接口,command有以下項:
a)   raw:發送一個原始的IPMI請求,並且打印回復信息。
b)   lan:配置網絡(lan)信道(channel)
c)   chassis :查看底盤的狀態和配置電源
d)   event:向BMC發送一個已定義的事件(event),可用於測試配置的SNMP是否成功
e)   mc:  查看MC(Management Contollor)狀態和各種允許的項
f)   sdr:打印傳感器倉庫中的任何監控項和從傳感器讀取到的值。
g)   sensor:打印周詳的傳感器信息。
h)   Fru:打印內建的Field Replaceable Unit (FRU)信息
i)   sel: 打印 System Event Log (SEL)      
j)   pef: 配置 Platform Event Filtering (PEF),事件過濾平台用於在監控系統發現有event時候,用PEF中的策略進行事件過濾,然后看是否需要報警。
k)   sol/isol:用於配置通過串口的Lan進行監控
l)   user:配置BMC中用戶的信息 。
m)  channel:配置Management Controller信道。

root@linux:~# ipmitool -I open sensor list Temp | na | degrees C | na | na | na | na | 85.000 | 90.000 | na Temp | na | degrees C | na | na | na | na | 85.000 | 90.000 | na Temp | na | degrees C | na | 64.000 | na | -128.000 | -128.000 | na | na Temp | na | degrees C | na | -128.000 | na | -96.000 | -27.000 | na | na Ambient Temp | 19.000 | degrees C | ok | na | 3.000 | 8.000 | 42.000 | 47.000 | na Planar Temp | na | degrees C | na | na | 3.000 | 8.000 | 92.000 | 97.000 | na

          2)通過網絡監控遠程服務器。

            被監控服務器需要硬件和操作系統接口驅動的支持,可以無需安裝應用軟件。監控客戶端需要應用軟件如ipmitool工具,可以無需硬件和操作系統接口驅動的支持。

            ipmi的遠程監控是通過向與BMC相連的網絡接口發送udp數據包實現的,udp數據包的定位是通過把ip地址寫BMC芯片來實現,而這需要本地的Ipmi系統接口來完成連接。Ipmitool可以通過LAN遠程監控系統,同時BMC中保存有一序列用戶名和密碼,通過LAN進行遠端訪問需要用戶名和密碼。

            被監控服務器使用ipmitool更改ip,查看ip      

root@linux:~# ipmitool lan set 1 ipaddr 172.16.6.222 Setting LAN IP Address to 172.16.6.222 root@linux:~# ipmitool lan print 1 Set in Progress : Set Complete Auth Type Support : NONE MD2 MD5 PASSWORD Auth Type Enable : Callback : MD2 MD5 : User : MD2 MD5 : Operator : MD2 MD5 : Admin : MD2 MD5 : OEM : IP Address Source : Static Address IP Address : 172.16.6.222 Subnet Mask : 255.255.255.0 MAC Address : a4:ba:db:4d:3f:2d SNMP Community String : public IP Header : TTL=0x40 Flags=0x40 Precedence=0x00 TOS=0x10 Default Gateway IP : 0.0.0.0 Default Gateway MAC : 00:00:00:00:00:00 Backup Gateway IP : 0.0.0.0 Backup Gateway MAC : 00:00:00:00:00:00 802.1q VLAN ID : Disabled 802.1q VLAN Priority : 0 RMCP+ Cipher Suites : 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14 Cipher Suite Priv Max : aaaaaaaaaaaaaaa : X=Cipher Suite Unused : c=CALLBACK : u=USER : o=OPERATOR : a=ADMIN : O=OEM

               監控客戶端Ipmi ip地址也必須和被監控服務端在同一網段,

root@ubuntu:~# ipmitool lan print 1 Set in Progress : Set Complete Auth Type Support : NONE MD2 MD5 PASSWORD Auth Type Enable : Callback : MD2 MD5 : User : MD2 MD5 : Operator : MD2 MD5 : Admin : MD2 MD5 : OEM : IP Address Source : Static Address IP Address : 172.16.6.175 Subnet Mask : 255.255.255.0 MAC Address : a4:ba:db:1b:81:48 SNMP Community String : public IP Header : TTL=0x40 Flags=0x40 Precedence=0x00 TOS=0x10 Default Gateway IP : 0.0.0.0 Default Gateway MAC : 00:00:00:00:00:00 Backup Gateway IP : 0.0.0.0 Backup Gateway MAC : 00:00:00:00:00:00 802.1q VLAN ID : Disabled 802.1q VLAN Priority : 0 RMCP+ Cipher Suites : 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14 Cipher Suite Priv Max : aaaaaaaaaaaaaaa : X=Cipher Suite Unused : c=CALLBACK : u=USER : o=OPERATOR : a=ADMIN : O=OEM
root@ubuntu:~# ifconfig eth0:1 172.16.6.252 netmask 255.255.255.0 root@ubuntu:~# ifconfig eth0 Link encap:Ethernet HWaddr a4:ba:db:1b:81:40 inet addr:10.1.6.175 Bcast:10.1.6.255 Mask:255.255.255.0 inet6 addr: fe80::a6ba:dbff:fe1b:8140/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:107931 errors:0 dropped:18357 overruns:0 frame:0 TX packets:12671 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:13418631 (13.4 MB) TX bytes:1551309 (1.5 MB) eth0:1 Link encap:Ethernet HWaddr a4:ba:db:1b:81:40 inet addr:172.16.6.252 Bcast:172.16.6.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:2 errors:0 dropped:0 overruns:0 frame:0 TX packets:2 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:178 (178.0 B) TX bytes:178 (178.0 B) root@ubuntu:~# ping 172.16.6.222 PING 172.16.6.222 (172.16.6.222) 56(84) bytes of data. 64 bytes from 172.16.6.222: icmp_req=1 ttl=64 time=0.458 ms 64 bytes from 172.16.6.222: icmp_req=2 ttl=64 time=0.514 ms

              能夠Ping通被監控服務器地址 則可以遠程管理該主機。

root@ubuntu:~# ipmitool -I lanplus -H 172.16.6.222 -U root -P password sol activate [SOL Session operational. Use ~? for help] LTS debian ttyS1 debian login:

             看到以上界面,說明客戶端已經可以登錄或查看被監控服務器。

以下是ipmitool在生產環境下常用命令:

查看ipmi信息 #ipmitool mc info
人員             #ipmitool user list 1

查看綁定IP  #ipmitool  lan print 1

更改IP   #ipmitool lan set 1 ipaddr  x.x.x.x

更改密碼 #ipmitool user list 1
              #ipmitool user set password 2 "123456"

ipmitool的SQL遠程控制服務器  #ipmitool -I lanplus -H x.x.x.x  -U  root -P  password sol (de)activate

強制重啟(關閉或開啟)被監控服務器     #ipmitool -I lanplus -H x.x.x.x -U root -P password chassis power reset (off on)

列出日志  ipmitool sel list

快捷鍵      shift + ~ +.  是退出ipmi

 

排除錯誤的第一點需要確信自己的IPMI配置生效了,但是這就需要運行ipmitool,但是自己的卻是桌面版Ubuntu,問題就在於這里如何能顧運行ipmitool呢?要么將系統換做服務器版,要么添加服務器包含的內核支持模塊。
     但是自己在網上看到另外一種說法,ipmitool獨立於系統,但是在linux下需要安裝一個OpenIpmi模塊;自己在工作站Ubuntu上試了試,雖然安裝了openipmi,安裝ipmitool后運行仍舊提示缺少device。最壞的情況就是要將系統換成服務器版了 

 

 

智能平台管理接口 (IPMI) 是一種開放標准的硬件管理接口規格,定義了嵌入式管理子系統進行通信的特定方法。IPMI 信息通過基板管理控制器 (BMC)(位於 IPMI 規格的硬件組件上)進行交流。使用低級硬件智能管理而不使用操作系統進行管理,具有兩個主要優點: 首先,此配置允許進行帶外服務器管理;其次,操作系統不必負擔傳輸系統狀態數據的任務。
ipmi在linux下的實現由幾個模塊組成:ipmi_msghandler,ipmi_devintf,ipmi_serial,ipmi_serial_codec*這幾個模塊分別負責不同的功能,它們互相協作完成ipmi的功能。其中ipmi serial被移除了linux內核,原因在linux的文檔中關於ipmi serial串口驅動中有所描述。但是在社區中仍有對它的支持。

一、ipmi_msghandler

該模塊是ipmi消息處理的核心,它不依賴於其它模塊,但是它也需要調用其它模塊的接口。為了實現這一點,它了解所有的IPMI的核心數據結構,它所需要調用的其它模塊的函數接口都通過數據結構中的指針來實現。因此可以這么說,該模塊對外提供了接口,當其它模塊需要該模塊提供服務時就直接調用其提供的接口,而當該模塊需要其他模塊的服務時,就通過相應數據結構中的指針來實現。該模塊維護了一個鏈表ipmi_interfaces,它包括了所有的ipmi接口。IPMI所涉及到的核心數據結構的關系如圖:

 

1.初始化/卸載

該模塊的初始化相對比較簡單,主要完成了

  • 注冊驅動
  • 創建proc文件
  • 啟動定時器ipmi_timer
  • 注冊到panic_block上

該模塊的卸載也相對比較簡單,就是初始化的逆過程

2.定時器處理

該模塊包括了一個定時器,它的處理函數中會重新啟動自己,因此它是一個定時到期的定時器。它完成的功能包括:

  • 每超時IPMI_REQUEST_EV_TIME次就調用一次ipmi_request_event,該函數最終會為每一個不工作在maintenance模式的並且在ipmi_interfaces鏈表中的接口調用一次它的request_events。
  • 調用ipmi_timeout_handler,該函數會遍歷所有的在ipmi_interfaces鏈表的接口,並且:
    • 對在接口的waiting_msgs鏈表中的消息調用handle_new_recv_msg處理消息
    • 對在接口的seq_table中的消息進行檢查處理
    • 進行maintenance模式的處理

3.與上層以及下層的接口

該模塊是ipmi消息處理的核心,它與上層,即直接用用戶空間交互的模塊已經下層即和真正的驅動交互的模塊都有接口。

  • 與上層的接口:該模塊提供了ipmi_create_user來讓上層創建一個user,同時要求上層提供與該user相關的struct ipmi_user_hndl,當本模塊需要向該user提交信息時,就通過該結構中的指針來完成。
  • 和下層的接口:該模塊提供了ipmi_register_smi來讓下層注冊一個smi,同時要求注冊者提供一個與該接口相關的struct ipmi_smi_handlers,當該模塊需要使用下層服務時,就會使用該結構中的指針。該模塊提供給下層的接口主要是ipmi_smi_msg_received

另外通過EXPORT_SYMBOL即可找到該模塊對外提供的所有接口。

4.發送消息/接收消息

1).發送消息

當上層發送消息時,它們需要使用該模塊提供的接口:

  • ipmi_request_settime
  • ipmi_request_supply_msgs
  • ipmi_request_with_source

來完成,這幾個函數最終會調到接口的handlers->sender來把消息交給下層。

2).接收消息

當下層收到消息時,會調用ipmi_smi_msg_received來將消息提交給本模塊。該函數會把消息添加到接口的waiting_msgs鏈表中,或者直接調用handle_new_recv_msg進行處理。handle_new_recv_msg會找到user並把消息通過與user關聯的struct ipmi_user_hndl提交給用戶。
需要注意的是,默認情況下只有消息會被提交給user,如果user想要接收命令,事件,就需要通過該模塊提供的接口ipmi_register_for_cmd以及ipmi_set_gets_events來告訴本模塊它關心這些信息。當它們不想繼續接收命令,事件時就需要 通過ipmi_unregister_for_cmd以及ipmi_set_gets_events來解除這種關心。

 

本模塊與其它模塊在消息收發上的接口如圖:

 

二、ipmi_devint

 

該模塊用於向用戶空間提供IPMI的接口。是內核和用戶空間的接口。該模塊依賴於模塊ipmi_msghandler。

1.初始化/卸載

在模塊初始化時會注冊一個名字為ipmidev的字符設備,並綁定相應的文件操作ipmi_fops。同時會通過ipmi_smi_watcher_register為所有在鏈表ipmi_interfaces中的接口創建設備文件,創建的設備文件名為ipmi%d,其中%d為接口的編號。
卸載時會先刪除所有設備文件,然后卸載字符設備ipmidev

2.和內核通信

如果想要和內核中的ipmi通信,首先需要打開一個設備文件ipmi%d。在打開設備文件時,本模塊會調用ipmi_create_user創建一個user,同時向ipmi_msghandler提供一個該user接收信息的回調函數,當ipmi_msghandler向該user提交信息時會用到該回調函數。
在打開一個設備文件后,即可使用ioctl和內核通信。

3.向外提供的接口

通過文件操作提供給用戶空間的接口
通過struct ipmi_user_hndl向ipmi_msghandler提供的接收消息的窗口

4.需要外部提供的接口

和接口設備文件相關的接口:
  • ipmi_smi_watcher_register
  • ipmi_smi_watcher_unregister
和user的創建和刪除相關的接口:
  • ipmi_create_user
  • ipmi_destroy_user
ioctl命令相關:
  • ipmi_validate_addr驗證地址
  • ipmi_addr_length獲得地址長度
  • ipmi_request_settime發送requset
  • ipmi_free_recv_msg釋放消息
  • ipmi_register_for_cmd注冊命令,即聲明自己關心這個命令
  • ipmi_unregister_for_cmd
  • ipmi_set_gets_events設置獲取事件標記,並獲取事件。甚至了標記則表明本user關心事件
  • ipmi_set_my_address
  • ipmi_get_my_address
  • ipmi_set_my_LUN
  • ipmi_get_my_LUN
  • ipmi_set_maintenance_mode
  • ipmi_get_maintenance_mode

5.發送/接收信息

接收信息:默認情況下,只有消息會被發送給user。這是通過和user關聯的ipmi_msghandler實現的,ipmi_msghandler會調用ipmi_msghandler中的file_receive_handler,該接口的會把消息放入一個user私有的接收消息列表中。當用戶發送接收消息的ioctl時,就會從該消息列表取出消息。
發送信息:用戶空間發送的requset通過ioctl命令到達內核后,最終通過ipmi_request_settime發送出去。

 

本模塊在收發消息上與其它模塊的接口如圖所示:

三、ipmi_serial

 

ipmi_serial模塊是ipmi的串口驅動,用於支持使用串口和bmc通信。該模塊是串口驅動的核心,當前串口驅動可以工作在三種模式,deriect,radysis_ascii,terminal。每種模式以一種ipmi_serial_codec表示。

該模塊維護了兩個鏈表,codec_list和info_list,前一種包括了當前系統中注冊的模式,后一個列表包括了當前系統中所配置的ipmiserial接口。

1.初始化/卸載

初始化的動作:根據模塊參數嘗試調用ipmi_serial_setup_one以創建一個ipmi serial interface。在ipmi_serial_setup_one中,會:

  • 創建新的struct ipmi_serial_info結構
  • 設置ipmi_serial_info中的定時器,該定時器會在調用ipmi_register_smi時被啟動
  • 解析參數並初始化infor結構
  • 如果是一個新的接口,就會被加入到info_list鏈表中,否則做清理工作后返回
  • 如果是一個新的接口,還會檢查所指定的模式是否已經加載(即是否已存在於codec_list中),如果已經存在,則會嘗試調用setup_intf創建一個接口。

setup_intf會完成最終的創建工作(部分工作是ipmi_serial_found完成的):

  • 找到實際的物理接口,即實際的serial接口,並將相關的信息傳遞給該serial接口,info->port->state->direct = &info->direct; 這一步很關鍵,serial驅動將使用這里的信息來完成信息的傳遞,即信息由serial驅動向ipmi serial接口的傳遞。
  • 調用串口的ops->startup
  • 設置serial的相關配置信息
  • 調用codec注冊的init函數
  • 如果codec有注冊start函數,則調用info->codec->init和info->codec->start來嘗試向BMC發送一個請求,並等待響應,收到響應則表示可以工作,否則就表示不能工作;如果沒有注冊start函數,則認為是可以工作的。
  • 調用ipmi_register_smi注冊接口到ipmi_msghandler,並提供相應的struct ipmi_smi_handlers給ipmi_msghandler使用
  • 創建相應的proc文件

卸載的工作:模塊卸載時做的事情很簡單,就是注冊的逆過程。的ipmi_serial_cleanup_one會完成實際的接口清理工作。在命令的處理中,以及在codec的unregister中也有調用該函數。

 

2.定時器

每個ipmi_serial_info都包括了一個定時器,它的處理函數中會重新啟動自己,因此它是一個定時到期的定時器。它完成的功能包括:

  • 增加timer_ticks計數
  • 調用timeout_handling,該函數在做了一些處理后,最終會調用start_next_msg,這是本模塊的核心處理函數,無論是發送還是接收,最終都由它處理。

3.和外部的接口

本模塊除了和上層(ipmi_msghandler)以及下層(所支持的codec)有接口外,還通過配置文件和用戶空間有一個關鍵接口。

1).和用戶空間的關鍵接口:

/sys/module/ipmi_serial/parameters/hotmod
可以通過如下命令來添加一個接口:
echo add,ttyS3,38400N81r,RadisysAscii > hotmod
該命令的處理函數為hotmod_handler,它會調用ipmi_serial_setup_one或ipmi_serial_remove_one(進一步的ipmi_serial_cleanup_one)

2).和上層的接口

該模塊和上層即 ipmi_msghandler的接口分為兩部分:

  • 本模塊提供給ipmi_msghandler的通過struct ipmi_smi_handlers提供給它
  • 本模塊需要的上層接口主要包括:
    • ipmi_register_smi
    • ipmi_smi_msg_received

3).本模塊和下層的接口

本模塊和下層(所支持的codec)的接口也分為兩部分:

  • 本模塊提供給下層的接口通過EXPORT_SYMBOL即可找到
  • 下層模塊提供給本模塊的接口包含在struct ipmi_serial_codec中,並通過ipmi_serial_codec_register提供給本模塊

4.發送消息/接收消息

1).發送消息

當上層發送消息時,它使用struct ipmi_smi_handlers中的sender(即ipmi_serial_sender)來將消息交給本模塊。
這個函數通過最終會通過start_next_msg調到info->codec->send_msg將信息提交給下層。之后,該消息在被codec模塊處理后又會被提交給本模塊的ipmi_serial_ll_xmit,最終通過uart_direct_write發送出去

2).接收消息

當下層收到消息時,會調用ipmi_serial_ll_recv來將消息提交給本模塊。這個函數最終會通過start_next_msg調到ipmi_smi_msg_received將消息提交給上層。
而serial驅動的信息則是通過info->direct中的指針進入ipmi serial的,實際上即進入到了info->codec->handle_char中。相關的代碼:
ipmi_serial_setup_one:
info->direct.direct_data = info;
      info->direct.handle_char = ipmi_serial_handle_char;
      info->direct.push = ipmi_serial_push;
     setup_intf:
            info->port->state->direct = &info->direct;
ipmi_serial_push:
        info->codec->handle_char

 

本模塊和其它模塊在消息收發上的接口如圖:

四、ipmi_serial_codec

IPMI serial支持幾種codec模式,這幾種模式可以理解為編解碼器,發送時進行編碼接收時進行解碼,對於每種模式來說,它只需要將其注冊到ipmi_serial並提供相應的編解碼功能所需的函數指針即可。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM