{"title": "\u901a\u8fc7Dell DRAC\u5e26\u5916\u83b7\u53d6\u4e3b\u673aSN", "update_time": "2013-06-29 23:30:37", "tags": "drac racadm", "pid": "194", "icon": "linux.png"}
有一批Dell的机器是通过DHCP的方式获取到主机的带外ip地址,并录入到了CMDB(基础信息库) 实际上我们可以ssh到DRAC获得的地址,并在上面执行命令来进行各种带外操作。 ssh到Dell的带外控制器DRAC后,可以方便地执行racadm命令,来做一些实用的带外管理工作。 具体的流程如下: 1. 先登录到带外ip(ssh 带外ip地址) 2. 获得命令行后,执行`racadm getsvctag` 那么我们要获取一堆带外IP对于的SN,可以使用expect来进行批量操作,我写了一个简单的脚本供大家参考: ``` #!/bin/bash ssh_expect() { which expect &>/dev/null if [ $? -ne 0 ] ; then yum -y install expect &>/dev/null which expect &>/dev/null if [ $? -ne 0 ] ; then echo "No expect found! SSH operations not supported." exit 2 fi fi expect <<EOF set timeout 16 spawn -noecho ssh -o StrictHostKeyChecking=no $1 "$3" expect { *assword:* { send "$2\n" expect { *denied* {exit 4} *closed* {exit 4} eof } } eof {exit 2} timeout {exit 2} } EOF return $? } for i in `cat ips` do ssh_expect root@$i "PASSWORD" "racadm getsvctag" done ``` 其中PASSWORD请改成实际的带外密码