Skip to content

Instantly share code, notes, and snippets.

@Dapacruz
Last active October 5, 2017 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dapacruz/111369c1883e84cc1b84fcaf9ce90781 to your computer and use it in GitHub Desktop.
Save Dapacruz/111369c1883e84cc1b84fcaf9ce90781 to your computer and use it in GitHub Desktop.
Get VMware ESXi vmnic LLDP info (get_vmhost_lldp_info.sh)
# 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
# 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