BMC中I2C 扫描(I2C-test)
## **i2c-test** 工具是Linux下在bmc系统下对i2c的一个扫描工具。
使用方法有:
- 对每个BUS进行扫描的时候,可采用i2c-test 对其进行扫描,可采用i2c-test --scan -b 0(对bus0进行扫描)。
- 如果对bus下面的每个channel 进行扫描时,需要进行切换,可使用i2c-test -b $i -s 0x70 -w 1 -d $j命令进行切换,i 表示bus,j 表示channel,i2c-test --scan -b $i.
- 自动登录BMC系统的方式为在TCL环境下,使用expect进行登录,完整的代码为:
#!/bin/bash
if [ $# -lt 2 ] ;then
red_message "Wrong Parameter"
exit 1
fi
BMCIP="$1"
#itc_change hl begin
ping -q -c 3 $BMCIP > /dev/null 2>&1
if [ $? -ne 0 ] ;then
echo "red_message[BMC unreachable !! IP:'$BMCIP'] exit 3" | tee -a ITC_LOG.LOG
exit 3
fi
#itc_change hl end
shift 表示右移
cmd="$@"
rm -rf /root/.ssh/known_hosts
which expect > /dev/null 2>&1
if [ $? -ne 0 ] ;then
red_message "Pleace install expect first !"
exit 2
fi
echo "#!/usr/bin/expect
set timeout -1 设置时间为-1
spawn ssh -o StrictHostKeyChecking=no sysadmin@${BMCIP} 登录BMC
expect \"*password:\"
send \"superuser\\r\"
expect \"*#\"
send \"$cmd\\r\"
expect \"*#\"
" >/tmp/scanbus${BMCIP}.sh
expect /tmp/scanbus${BMCIP}.sh 2>/dev/null
查询BMCIP的命令为:
BMCIP=`ipmitool lan print|awk '/IP Address / {print $NF}'`