当前位置: 首页 > 工具软件 > ipmitool > 使用案例 >

ipmitool命令

韦高谊
2023-12-01

远程获取服务器监控信息

      远程获取服务器监控信息时,需要系统硬件支持ipmiV1.5和IPMIV2.0。获取信息时,不需要在服务器上安装其他软件,只需要在监控的客户端上安装ipmi工具软件,如ipmitool,并需要在相应命令中加入远端服务器的名字或者地址。Ipmitool和 ipmiutil可以通过LAN远程监控系统,同时BMC中保存有一序列用户名和密码,通过LAN进行远端访问需要用户名和密码。

     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命令的使用

1. 查看设备信息

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin chassis status

2. 查看用户

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin user list

3. 增加用户

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin user set name 3 test1

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin user list

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin user set password 3 test1

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin user priv 3 20

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin user list

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U test1 -P test1 user list

4. disable/enable用户

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin user disable 3

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U test1 -P test1 user list

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin user enable 3

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U test1 -P test1 user list

5. 查看服务器当前开电状态

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin power status

6. 服务器的开机,关机,resetpower cycle

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin power on

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin power off

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin power cycle

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin power reset

7. 查看服务器的80 Port当前状态

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin raw 0x30 0xB2

8. 查看服务器的传感器状态

所有传感器状态详细信息:

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin sensor

传感器SDR summary信息:

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin sdr info

传感器SDR 列表信息:

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin sdr list

FRU传感器SDR 列表信息:

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin sdr list fru

下载RAW SDR信息到文件:

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin sdr dump sdr.raw

9. 查看服务器的FRU信息

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin fru

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin fru print

10. 在系统中,设定系统下一次启动时为pxe重启模式

ipmitool chassis bootdev pxe

ipmitool chassis power reset  硬重启

ipmitool chassis bootdev disk   从磁盘启动

ipmitool chassis bootdev cdrom  从光驱启动

================

BMC自身配置命令

================

1. 查看BMC的信息

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin mc info

2. 查看BMCLAN信息

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin lan print 1

(一般channel 1LAN

3. 修改BMCMAC信息(只能在本地以root用户做,因为在此之前没IP

enable BMC MAC SET mode:

/usr/bin/ipmitool raw 0x0c 0x01 0x01 0xc2 0x00

Write MAC to BMC (BMC MAC=d0:27:88:a4:e4:37):

/usr/bin/ipmitool raw 0x0c 0x01 0x01 0x05 0xD0 0x27 0x88 0xA4 0xE4 0x37

4. 修改BMC的网络为自动从DHCP获得IP地址,而不是静态的(只能在本地以root用户做,因为在此之前没IP

确定channel 1LAN:

/usr/bin/ipmitool lan print 1

设定channel 1DHCP获得IP:

/usr/bin/ipmitool lan set 1 ipsrc dhcp

5. 重启BMC自己(不是服务器)(小心BMC挂掉hang

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin mc reset

================

SOL和通过IPMItool访问系统终端 (Serial-Over-LAN)

================

1. 查看当前的SOL summary信息

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin sol info 1

 

2. 修改SOL配置信息

查看所有可能的配置

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin sol set

修改波特率配置

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin sol set non-volatile-bit-rate 38.4 1

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin sol set volatile-bit-rate 38.4 1

 

3. 开启远程终端

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin sol activate

(可以使用~.退出,~?显示帮助信息)

 

================

Watchdog配置命令

================

1. 查看当前的watchdog信息

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin mc watchdog get

 

2. 设置,开启一个watchdog

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin mc watchdog get

设置一个OS WDTwatchdog, 超时时间为60秒(自己看IPMI 2.0手册,351页的27.6 Set Watchdog Timer Command(60x10=600 = 0x258)

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin raw 0x06 0x24 0x04 0x01 0x00 0x10 0x58 0x2

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin mc watchdog get

开启该watchdog

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin mc watchdog reset

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin mc watchdog get

 

禁止该watchdog的动作(Hard reset-> no action)

 

/usr/bin/ipmitool -I lanplus -H 10.32.228.187 -U sysadmin -P admin raw 0x06 0x24 0x04 0x00 0x00 0x10 0x58 0xFF

 

上面的命令把时间改为非常大,提示第10x00表示没有动作,0x04表示是SMS/OSwatchdog, 0xFF58是超时的时间,单位为100ms

 

================

SEL命令

================

1. 查看当前的SEL summary信息

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin sel

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin sel info

 

2. 列示所有SEL记录详细信息

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin sel list

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin sel list 10

 

3. 删除指定的SEL记录

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin sel delete 1

 

4. 清除所有的SEL记录

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin sel clear

 

5. 获取和修改SEL当前时钟

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin sel time get

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin sel time set "04/24/2012 18:44:44"

 

6. RAW方式查看制定的SEL数据

 

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin raw 0xa 0x43 0 0 111 0 0 0xFF

 

0xa 0x43Get SEL Entry Command 0 0 保留值,111 0 表示取第112条记录(从0开始),0 offset,保留;0xFF为读取的字节数,FF表示取整条记录

 

================

PEF命令

================

1. 查看BMC当前的PEF 支持信息

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin pef

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin pef info

 

2. 查看BMC当前的PEF 配置表信息(配置表也是可以修改的)

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin pef list

 

3. 查看BMC当前的PEF 状态信息(BMC处理的最后一条SEL记录)

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin pef status

 

4. 修改BMC当前的PEF 配置表

查看当前的PEF 配置表

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin pef list

假定我们要删除下面这条配置项

1 | active, pre-configured | 0x11 | Voltage | Any | None | OEM | Any | Power-off,OEM-defined

获取该配置项的配置信息

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin raw 0x04 0x13 0x07 0x01 0x00

11 01 40

修改该配置项的配置信息

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin raw 0x04 0x12 0x07 0x01 0x40

检查修改后的PEF配置表

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin pef list

 

================

特殊命令

================

1. 查看ipmi服务器端当前活动的session会话

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin session info active

 

2. 执行一个保存在文件中的所有ipmitool命令

/usr/bin/ipmitool -I lanplus -H 10.32.228.168 -U sysadmin -P admin exec myipmi.cmd

 

3RH2885修改风扇转速

  调整为100% 1ipmitool -I lan -H 192.168.52.27 -U root -P root raw 0x30 0x91 0xdb 0x07 0x00 0x01 0x01 0 0 0 0

                       2ipmitool -I lan -H 192.168.52.27 -U root -P root raw 0x2c 0x15 0x00 0x00 0x64

  还原:       ipmitool -I lan -H 192.168.52.27 -U root -P root raw 0x30 0x91 0xdb 0x07 0x00 0x01 0x00 0 0 0 0

 

 

获取CPU和内存的温度(这里cpu是相对温度,内存是绝对温度)

ipmitool -b 6 -t 0x2c raw 0x2e 0x4b 0x57 0x01 0x00 0x03 0xff 0xff 0xff 0xff 0x00 0x00 0x00 0x00

ipmitool -b 6 -t 0x2c raw 0x2e 0x4b 0x57 0x01 0x00 0x83 0xff 0xff 0xff 0xff 0x00 0x00 0x00 0x00

返回示例:

 57 01 00 15 1d 32 33 ff ff 32 ff ff ff 20 ff ff

 ff 25 ff ff ff 23 25 ff ff 24 ff ff ff 30 ff ff

 ff 31 ff ff ff

 

 

service ipmi start

ipmitool lan set 1 ipsrc static

ipmitool lan set 1 ipaddr  172.16.1.16

ipmitool lan set 1 netmask 255.255.255.0

ipmitool lan set 1 defgw ipaddr  172.16.1.1

ipmitool mc reset cold

ipmitool lan set 1 access on

 

sed -i 's/10.32.11.1/192.168.1.1/g' /etc/rc.d/rc.local

ipmitool lan print 1

ipmitool user set password <user id> [<password>]

 

ipmitool user set name 3 ADMIN

ipmitool user set password 3 ADMIN

ipmitool  raw 0x30 0x93 0xdb 0x07 0x00 0x22 0x00

ipmitool raw 0x30 0x93 0xdb 0x07 0x00 0x22 0x00 取消密码复杂度

设置用户权限

 

channel 1user ID3privilege4

 

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

 

 

nnel 1user ID3privilege4

 

privilege的值定义如下;

 

1 callback

2 user

3 operator

4 administrator

5 OEM

 

#ipmitool lan set 1 ipaddr *.*.*.*

#ipmitool lan set 1 netmask *.*.*.*

#ipmitool lan set 1 defgw ipaddr *.*.*.*

#ipmitool lan set 1 access on

 

interface的使用

-I interface

open

lan

lanplus

其他

如果没有-I选项,ipmitool默认使用open,即Linux OpenIPMI

 

lanpluslan的增强版

lanlanplus主要用于远程监控

 

获取传感器数据

传感器简洁数据

左边第一列是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

1

只能获取到第一个Sensor ID的数据。

 

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

 

例如CPU1entity 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

 

打印系统事件log

 

#ipmitool sel list

 

2

如何找到帮助信息

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

1

下面这个也会出现同样的问题

# ipmitool  user priv 7 admin

 

参考文档:https://www.annhe.net/article-2987.html

 

 类似资料: