Skip to content

Instantly share code, notes, and snippets.

@raspi
raspi / esxi_lldp_control.sh
Last active January 11, 2023 15:35
Enable/Disable LLDP on VMWare ESXi. Requires SSH access to ESXi. Doesn't require vCenter.
#!/bin/sh
# Enable/Disable LLDP on vSwitch ports on VMWare ESXi
# Tested with ESXi 6.0.0 3620759
# Doesn't need vCenter, only SSH access to the ESXi machine
# (c) Pekka "raspi" Jarvinen 2016 http://raspi.fi/
SWITCH=$1
OPERATION=$2
if [ "$SWITCH" = "" ] || [ "$OPERATION" = "" ]; then
@AnthonyWC
AnthonyWC / vswitch-lldp.sh
Created March 3, 2016 19:10
Enable vSwitch LLDP for all VMNIC interfaces
VSISH_VSWITCH_PATH=/net/portsets
for vSwitch in $(vsish -e ls ${VSISH_VSWITCH_PATH});
do
VSWITCH=$(echo ${vSwitch} | sed 's/\///g')
for port in $(vsish -e ls ${VSISH_VSWITCH_PATH}/${vSwitch}ports);
do
PORT=$(echo ${port} | sed 's/\///g')
PORTINFO=$(vsish -e get ${VSISH_VSWITCH_PATH}/${vSwitch}ports/${port}status | sed 's/^[ \t]*//;s/[ \t]*$//');
CLIENT=$(echo ${PORTINFO} | sed 's/ /\n/g' | grep "clientName:" | awk -F ":" '{print $2}')
MACADDRESS=$(echo ${PORTINFO} | sed 's/ /\n/g' | grep "unicastAddr:" | uniq | sed 's/unicastAddr://;s/\(.*\)./\1/')

Using aws-cli and jq

list all instances for all ASGs

aws autoscaling describe-auto-scaling-instances \
  | jq '.AutoScalingInstances[] | {AutoScalingGroupName, InstanceId}'

list instance IDs for a particular ASG

@hummus
hummus / gist:8592113
Last active February 8, 2024 07:35
aws cli + jq example
wget http://stedolan.github.io/jq/download/linux64/jq
aws ec2 describe-instances --filters "Name=tag:Name,Values=$NAME" \
"Name=instance-state-name,Values=running" \
| jq -r \
".Reservations[] | .Instances[] | .InstanceId" \
aws ec2 describe-volumes --filters \
"Name=status,Values=available" \
| jq -r ".Volumes[] | .VolumeId" \