ipmitool 常用命令 IPMI

前端之家收集整理的这篇文章主要介绍了ipmitool 常用命令 IPMI前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

[root@localhost ~]# yum install -y ipmitool #安装这个包


电源相关:


#开启电源

ipmitool -I lanplus -H 10.41.1.41 -U root -P root power on


#关闭电源

ipmitool -I lanplus -H 10.41.1.41 -U root -P root power off


#重启电源

ipmitool -I lanplus -H 10.41.1.41 -U root -P root power reset


#查看电源状态

ipmitool -I lanplus -H 10.41.1.41 -U root -P root power status


启动项相关:


#设置为BIOS启动

ipmitool -I lanplus -H 10.41.1.41 -U root -P root chassis bootparam set bootflag force_bios


#设置为pxe启动


ipmitool -I lanplus -H 10.41.1.41 -U root -P root chassis bootparam set bootflag force_pxe


#设置为光盘启动

ipmitool -I lanplus -H 10.41.1.41 -U root -P root chassis bootparam set bootflag force_cdrom


#设置为硬盘启动

ipmitool -I lanplus -H 10.41.1.41 -U root -P root chassis bootparam set bootflag force_disk


#重启BMC

ipmitool -I lanplus -H 10.41.1.41 -U root -P root mc reset cold


#修改BMC密码

ipmitool -I lanplus -H 10.41.1.41 -U root -P root user set password 2 new_password #new_password 这个是新密码


#远程文本重定向 重启服务器就能看到画面

ipmitool -I lanplus-H 10.41.1.41 -U root -P root sol activate


#当有这个错误时Info: SOL payload already active on another session

ipmitool -I lanplus-H10.41.1.41-U root -P root soldeactivate #这命令是踢出其他的人会话


#获取mac地址 有些机型不准 我这个是dell的服务器 华为服务器也可以使用

"""ipmitool -I lanplus -H 10.41.1.41 -U root -P root lan print |grep "MAC Address"|awk '{print $NF}'"""


python 脚本

fromsubprocessimportPopen,PIPE
cmd="""ipmitool-Ilanplus-H10.41.1.41-Uroot-Prootlanprint|grep"MACAddress"|awk'{print$NF}'"""
text=Popen(cmd,stdout=PIPE,shell=True).stdout.read()
prefix_mac=text[:-3]
last_two=text[-2:]
plus_one=int(last_two,16)-2
plus_one2=int(last_two,16)-1
new_last_two=hex(plus_one)[2:]
new_last_two2=hex(plus_one2)[2:]
iflen(new_last_two)==1:
new_last_two='0'+new_last_two
iflen(new_last_two2)==1:
new_last_two2='0'+new_last_two2
new_mac=prefix_mac.replace(':','')+new_last_two
new_mac2=prefix_mac.replace(':','')+new_last_two2
print(new_mac,new_mac2)

获取网卡1mac地址和网卡2mac地址



参考:

http://blog.csdn.net/zygblock/article/details/53431972

原文链接:https://www.f2er.com/bash/389985.html

猜你在找的Bash相关文章