大家好,欢迎来到IT知识分享网。
ipmitool命令
ipmitool –I [open|lan|lanplus] command
OpenIPMI接口,command有以下项:
raw:发送一个原始的IPMI请求,并且打印回复信息。
lan:配置网络(lan)信道(channel)
chassis :查看底盘的状态和设置电源
event:向BMC发送一个已经定义的事件(event),可用于测试配置的SNMP是否成功
mc:查看MC(Management Contollor)状态和各种允许的项
sdr:打印传感器仓库中的所有监控项和从传感器读取到的值。
sensor:打印详细的传感器信息。
fru:打印内建的Field Replaceable Unit (FRU)信息
sel: 打印 System Event Log (SEL)
pef:设置 Platform Event Filtering (PEF),事件过滤平台用于在监控系统发现有event时候,用PEF中的策略进行事件过滤,然后看是否需要报警。
sol/isol:用于配置通过串口的Lan进行监控
user:设置BMC中用户的信息 。
channel:设置Management Controller信道。
ipmitool chassis
ipmitool chassis
ipmitool chassis identify #蓝色uid指示灯,直接执行命令,只能维持15秒
ipmitool chassis status
System Power : on #开机状态
Power Overload : false #是否过载
Power Interlock : inactive
Main Power Fault : false #主电源是否故障
Power Control Fault : false
Power Restore Policy : always-on #上电后机器的响应状态
Last Power Event : command
Chassis Intrusion : inactive
Front-Panel Lockout : inactive
Drive Fault : false #是否有硬盘告警
Cooling/Fan Fault : false #是否存在风扇告警
Sleep Button Disable : allowed
Diag Button Disable : allowed
Reset Button Disable : allowed
Power Button Disable : allowed
Sleep Button Disabled: false
Diag Button Disabled : false
Reset Button Disabled: false
Power Button Disabled: false
ipmitool chassis bootdev pxe #下次启动默认从网卡启动,只一次有效
ipmitool chassis bootdev disk #下次启动默认从硬盘启动
ipmitool chassis bootdev pxe options=persistent #永久生效
ipmitool chassis power status | on |reset
sensor查看
ipmitool sensor
fru读取和设置
ipmitool fru
ipmitool fru edit
ipmitol user 命令
- 查看用户
ipmitool user list
- 添加用户
ipmitool user set name 4 abcd #新增用户abcd
- 设置密码
ipmitool user set password 4 wifi@LS123
- enable/disable用户
ipmitool user enable 4
channel参数
命令使用:
- 查看指定用户权限
- 修改权限
ipmitool channel setaccess 2 “4” privilege=4 ipmi=on link=on callin=on
mc参数
ipmitool mc info #查看bmc固件版本
ipmitool mc reset cold #重启bmc
lan参数
- 查看网络信息
ipmitool lan print
Set in Progress : Set Complete
Auth Type Support : MD5
Auth Type Enable : Callback : MD5
: User : MD5
: Operator : MD5
: Admin : MD5
: OEM : MD5
IP Address Source : DHCP Address
IP Address :
Subnet Mask :
MAC Address :
SNMP Community String : AMI
IP Header : TTL=0x40 Flags=0x40 Precedence=0x00 TOS=0x10
BMC ARP Control : ARP Responses Enabled, Gratuitous ARP Disabled
Gratituous ARP Intrvl : 0.0 seconds
Default Gateway IP : 10.3.67.254
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,6,7,8,11,12,15,16,17
Cipher Suite Priv Max : caaaaaaaaaaaXXX
: X=Cipher Suite Unused
: c=CALLBACK
: u=USER
: o=OPERATOR
: a=ADMIN
: O=OEM
- 修改IP为静态还是DHCP模式
ipmitool lan set 1 ipsrc dhcp | static
- 修改IP地址
ipmitool lan set <ChannelNo> ipaddr <IPAddress>
# ipmitool lan set 1 ipaddr 192.168.2.60
- 修改子网掩码
ipmitool lan set <ChannelNo> netmask <NetMask>
# ipmitool lan set 1 netmask 255.255.0.0
- 修改默认网关
ipmitool lan set <ChannelNo> defgw ipaddr <Gateway >
# ipmitool lan set 1 defgw ipaddr 192.168.2.1
问题:
ipmitool lan set 1 ipsrc static
Channel 1 is not a LAN channel!
解决方法:帮助确认查找channel
for i in `seq 1 14`; do ipmitool lan print $i 2>/dev/null | grep -q ^Set && echo Channel $i; done
sel参数
ipmitool sel list #读取sel时候,建议使用elist,直接使用list,有些字段不能被完整解析
[root@test01 ~]# cat ipmi_tool.sh
#!/bin/sh
#description: ipmitool command tool
#author: liuxin
#date: 20180117
function usage()
{
cat << EOF
ipmi_tool.sh: ipmitool command tool
Usage: ipmi_tool.sh [options...] <command>
-f The file of remote host name for LAN interface
-u Remote session username, default value in this shell
-p Remote session password, default value in this shell
Help options:
-h Show this help message
EOF
return 0
}
function get_params()
{
[[ $# -lt 1 ]] && usage && exit 0
while getopts :hu:p:f: opt
do
case "$opt" in
h) usage && exit 0 ;;
u) USERNAME="$OPTARG" ;;
p) PASSWORD="$OPTARG" ;;
f|-file) HOST_FILE="$OPTARG" ;;
*) echo "Unknown option: $opt" && exit 1 ;;
esac
done
shift $[ $OPTIND - 1 ]
COMMAND="$@"
if [ -z "$COMMAND" ]
then
echo "command is null" && exit 1
fi
return 0
}
function print_params()
{
echo "USERNAME: $USERNAME"
echo "PASSWORD: $PASSWORD"
echo "HOST_FILE: $HOST_FILE"
echo "COMMAND: $COMMAND"
return 0
}
function ipmitool_run()
{
cat $HOST_FILE |grep -v '^#' |while read ip
do
received=$(ping $ip -c 5 -i 0.01 |egrep -o '[0-9] received' |awk '{print $1}')
echo -en "$ip\t$COMMAND:\t"
if [ $received -gt 0 ]
then
echo "ipmitool -I lanplus -U $USERNAME -P $PASSWORD -H $ip $COMMAND"
#ipmitool -I lanplus -U $USERNAME -P $PASSWORD -H $ip $COMMAND
else
echo "Unreachable"
fi
done
return 0
}
function main
{
USERNAME="root"
PASSWORD="123456"
HOST_FILE=""
COMMAND=""
get_params $@
ipmitool_run
#print_params
return 0
}
#--------------------
main $@
[root@test01 ~]# cat ip.txt
192.168.1.1
192.168.1.2
192.168.1.60
[root@test01 ~]# ./ipmi_tool.sh -f ./ip.txt chassis power reset
192.168.1.1 chassis power reset: ipmitool -I lanplus -U root -P 123456 -H 192.168.1.1 chassis power reset
192.168.1.2 chassis power reset: Unreachable
192.168.1.60 chassis power reset: ipmitool -I lanplus -U root -P 123456 -H 192.168.1.60 chassis power reset
[root@test01 ~]# ./ipmi_tool.sh -u admin -p pass -f ./ip.txt chassis power reset
192.168.1.1 chassis power reset: ipmitool -I lanplus -U admin -P pass -H 192.168.1.1 chassis power reset
192.168.1.2 chassis power reset: Unreachable
192.168.1.60 chassis power reset: ipmitool -I lanplus -U admin -P pass -H 192.168.1.60 chassis power reset
https://www.jianshu.com/p/164df74d5dac
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/24487.html