目前要通过ipmitool工具在IPMI的界面上添加邮件服务器地址,该脚本如下
SMTP.sh
#!/bin/bash ipmitool raw 0x32 0x78 0x01 0x01 0x00 0x00 0x14 0x00 0x02 0x10 ipmitool raw 0x32 0x78 0x01 0x00 0x00 0x00 0x01 ipmitool raw 0x32 0x78 0x01 0x02 0x00 0x00 ipmitool raw 0x32 0x78 0x1 0x8 0x0 0x0 0x67 0x69 0x6f 0x30 0x31 0x37 0x40 0x62 0x6d 0x63 0x2e 0x63 0x6f 0x6d
# g i o 0 1 7 @ b m c . c o m ipmitool raw 0x32 0x78 0x01 0x08 0x00 0x01 ipmitool raw 0x32 0x78 0x01 0x08 0x00 0x02 ipmitool raw 0x32 0x78 0x01 0x08 0x00 0x03 ipmitool raw 0x32 0x78 0x01 0x09 0x00 0x00 0x67 0x69 0x6f 0x30 0x31 0x37
# g i o 0 1 7
ipmitool raw 0x32 0x78 0x01 0x09 0x00 0x01 ipmitool raw 0x32 0x78 0x01 0x09 0x00 0x02 ipmitool raw 0x32 0x78 0x01 0x09 0x00 0x03 ipmitool raw 0x32 0x78 0x01 0x0b 0x00 0x00 0x00 ipmitool raw 0x32 0x78 0x01 0x0a 0x00 0x00 0x19 0x00 ipmitool raw 0x32 0x78 0x01 0x0e 0x00 0x00 0x00 0x00 0x00 0x00 ipmitool raw 0x32 0x78 0x01 0x0f 0x00 0x00 0x00 ipmitool raw 0x32 0x78 0x1 0x11 0x0 0x0 0x67 0x69 0x6f 0x30 0x31 0x37 0x40 0x62 0x6d 0x63 0x2e 0x63 0x6f 0x6d ipmitool raw 0x32 0x78 0x01 0x11 0x00 0x01 ipmitool raw 0x32 0x78 0x01 0x11 0x00 0x02 ipmitool raw 0x32 0x78 0x01 0x11 0x00 0x03 ipmitool raw 0x32 0x78 0x01 0x12 0x00 0x00 0x67 0x69 0x6f 0x30 0x31 0x37 ipmitool raw 0x32 0x78 0x01 0x12 0x00 0x01 ipmitool raw 0x32 0x78 0x01 0x12 0x00 0x02 ipmitool raw 0x32 0x78 0x01 0x12 0x00 0x03 ipmitool raw 0x32 0x78 0x01 0x14 0x00 0x00 0x00 ipmitool raw 0x32 0x78 0x01 0x13 0x00 0x00 0x19 0x00
现在要自动获取每个io节点hostname,并将节点hostname自动转换为十六进制数替换上面脚本的红色部分。
SMTP1.1.sh
#!/bin/bash hostname=`hostname` #echo $hostname if [ $# -ne 3 ];then echo "Usage: number1 number2 number3" exit 1 fi #a= echo $hostname | cut -c 4 x=`printf "0x%.2x" "'$1'"` #将字符ASCII自动转换为16进制数 0x30
echo $x #b= echo $hostname | cut -c 5 y=`printf "0x%.2x" "'$2'"` echo $y #c= echo $hostname | cut -c 6 z=`printf "0x%.2x" "'$3'"` echo $z ipmitool raw 0x32 0x78 0x01 0x01 0x00 0x00 0x14 0x00 0x02 0x10 ipmitool raw 0x32 0x78 0x01 0x00 0x00 0x00 0x01 ipmitool raw 0x32 0x78 0x01 0x02 0x00 0x00 ipmitool raw 0x32 0x78 0x1 0x8 0x0 0x0 0x62 0x69 0x6f $x $y $z 0x40 0x62 0x6d 0x63 0x2e 0x63 0x6f 0x6d ipmitool raw 0x32 0x78 0x01 0x08 0x00 0x01 ipmitool raw 0x32 0x78 0x01 0x08 0x00 0x02 ipmitool raw 0x32 0x78 0x01 0x08 0x00 0x03 ipmitool raw 0x32 0x78 0x01 0x09 0x00 0x00 0x62 0x69 0x6f $x $y $z
SMTP1.2.sh
#!/bin/bash host=`hostname` a=`echo $host | cut -c 4` b=`echo $host | cut -c 5` c=`echo $host | cut -c 6` #echo a:$a #echo b:$b #echo c:$c sh SMTP-test.sh $a $b $c ~
自动获取节点hostname,并将节点hostname自动转换为16进制数,替换执行。执行成功后IP MI的界面会自动添加本地目的邮件的地址。