XenServer5.6下编写,用于获取所有VM虚拟机IP和对应MAC地址,Shell脚本如下:
#!/bin/bash
#https://www.haiyun.me
if [[ ! -e mac-ip.txt ]];
then
touch mac-ip.txt
else
> mac-ip.txt
fi
for vps in `xe vm-list |awk '/name/ {print $4}'`
do
case $vps in
*"Control"* ) continue ;;
esac
writeline=`xe vif-list vm-name-label=$vps params=MAC|awk '/MAC/ {print $5}'`
writeline+=" "
writeline+=`xe vm-list name-label=$vps params=networks|awk '/network/ {print $5}'`
echo $writeline >> mac-ip.txt
done
XenServer获取VM虚拟机名称与MAC地址参考:https://www.haiyun.me/archives/xenserver-vmname-mac.html。