Last active
October 5, 2017 16:39
-
-
Save Dapacruz/111369c1883e84cc1b84fcaf9ce90781 to your computer and use it in GitHub Desktop.
Get VMware ESXi vmnic LLDP info (get_vmhost_lldp_info.sh)
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
# VMware ESXi shell script | |
# Get LLDP info for vmnics (use the get_vmhost_lldp_info_raw function if output is not complete) | |
vmnics="vmnic4 vmnic5" | |
get_vmhost_lldp_info(){ | |
for vmnic in $vmnics; do | |
printf "$vmnic [=]----[=] " | |
pktcap-uw --uplink $vmnic --ethtype 0x88cc -c 1 -o /tmp/vmnic_lldp.pcap > /dev/null | |
hexdump -C /tmp/vmnic_lldp.pcap | awk -F'|' '{printf $2}' | | |
sed -E 's|.+\.([etgETG][teiTEI][a-zA-Z]+ ?-?([0-9]+/)+[0-9]+)(.\.+.{1,2}\.+)+([a-zA-Z][a-zA-Z0-9]+)\..*|\1 (\4)\n|' | |
done;} | |
clear; printf "Listening for LLDP ...\n\n"; get_vmhost_lldp_info; echo |
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
# VMware ESXi shell script | |
# Get LLDP info for vmnics (raw output) | |
vmnics="vmnic4 vmnic5" | |
get_vmhost_lldp_info_raw(){ | |
for vmnic in $vmnics; do | |
printf "$vmnic:\n" | |
pktcap-uw --uplink $vmnic --ethtype 0x88cc -c 1 -o /tmp/vmnic_lldp.pcap > /dev/null | |
hexdump -C /tmp/vmnic_lldp.pcap | awk -F'|' '{print $2}' | |
done;} | |
clear; printf "Listening for LLDP ...\n\n"; get_vmhost_lldp_info_raw; echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment