Last active
October 5, 2017 16:54
-
-
Save Dapacruz/87d081e833dbf3deb8fdf7b640c819a5 to your computer and use it in GitHub Desktop.
Ping All VMware ESXi IP Addresses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get a list of IP addresses with PowerCLI | |
$Vmhosts = 'sac0esxi*' | |
$Vmks = 'vmk2', 'vmk3', 'vmk5', 'vmk6' | |
Get-VMHostNetworkAdapter -VMHost $Vmhosts -Name $Vmks | sort VMHost, Name | ft -auto VMHost, Name, IP | |
# ESXi host Bash function to ping all iSCSI addresses | |
ping_iscsi () { | |
mtu=8972 | |
failures=0 | |
vmks="vmk2 | |
vmk3 | |
vmk5 | |
vmk6" | |
addrs="10.10.100.3 | |
10.10.100.6 | |
10.10.100.7 | |
10.10.100.11 | |
10.10.100.12 | |
10.10.100.13 | |
10.10.100.14 | |
10.10.100.15 | |
10.10.100.16" | |
for addr in $addrs | |
do | |
for vmk in $vmks | |
do | |
count=$(ping -c 1 -W .1 -I $vmk -d -s $mtu $addr | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }') | |
if [ $count -eq 0 ]; then | |
echo "Ping failed: $addr ($vmk)" | |
let failures=failures+1 | |
fi | |
done | |
done | |
echo | |
if [ $failures -eq 0 ]; then | |
echo "Ping sweep complete. No failures detected." | |
else | |
echo "Ping sweep complete. Failures detected: $failures." | |
fi | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get a list of IP addresses with PowerCLI | |
$Vmhosts = 'sac0*' | |
$Vmks = 'vmk0' | |
Get-VMHostNetworkAdapter -VMHost $Vmhosts -Name $Vmks | sort VMHost, Name | ft -auto VMHost, Name, IP | |
# ESXi host Bash function to ping all management addresses | |
ping_mgmt () { | |
mtu=1472 | |
failures=0 | |
vmks="vmk0" | |
addrs="10.1.15.130 | |
10.1.15.120 | |
10.1.15.40 | |
10.1.15.20 | |
10.1.15.30" | |
for addr in $addrs | |
do | |
for vmk in $vmks | |
do | |
count=$(ping -c 1 -W .1 -I $vmk -d -s $mtu $addr | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }') | |
if [ $count -eq 0 ]; then | |
echo "Ping failed: $addr ($vmk)" | |
let failures=failures+1 | |
fi | |
done | |
done | |
echo | |
if [ $failures -eq 0 ]; then | |
echo "Ping sweep complete. No failures detected." | |
else | |
echo "Ping sweep complete. Failures detected: $failures." | |
fi | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get a list of IP addresses with PowerCLI | |
$Vmhosts = 'ndesx*' | |
$Vmks = 'vmk1', 'vmk7' | |
Get-VMHostNetworkAdapter -VMHost $Vmhosts -Name $Vmks | sort VMHost, Name | ft -auto VMHost, Name, IP | |
# ESXi host Bash function to ping all vMotion addresses | |
ping_vmotion () { | |
mtu=1472 | |
failures=0 | |
vmks="vmk0" | |
addrs="10.1.15.130 | |
10.1.15.120 | |
10.1.15.40 | |
10.1.15.20 | |
10.1.15.30" | |
for addr in $addrs | |
do | |
for vmk in $vmks | |
do | |
count=$(ping -c 1 -W .1 -I $vmk -d -s $mtu $addr | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }') | |
if [ $count -eq 0 ]; then | |
echo "Ping failed: $addr ($vmk)" | |
let failures=failures+1 | |
fi | |
done | |
done | |
echo | |
if [ $failures -eq 0 ]; then | |
echo "Ping sweep complete. No failures detected." | |
else | |
echo "Ping sweep complete. Failures detected: $failures." | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment