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并提供相应的编解码功能所需的函数指针即可。

posted @ 2018-05-21 23:42  konglingbin  阅读(35686)  评论(2编辑  收藏  举报