Skip to content

Instantly share code, notes, and snippets.

@drsnyder
Created October 22, 2012 18:43
Show Gist options
  • Select an option

  • Save drsnyder/3933307 to your computer and use it in GitHub Desktop.

Select an option

Save drsnyder/3933307 to your computer and use it in GitHub Desktop.
Where is that vip?
#!/bin/bash
for varnish in $*; do
echo "getting interfaces from $varnish"
ssh $varnish ifconfig > /tmp/$varnish
awk '/^eth1:/{printf $1;next;}1' /tmp/$varnish | grep eth1 | sed 's/^.*inet addr:\([0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\).*$/\1/' > /tmp/$varnish.ips
done
for vhost in `huddler-config -D | grep -v '^#' | awk '{ if ($6 == "prod") { print $1 } }'`; do
ip=$(dig $vhost +short | tail -1)
found=0
for varnish in $*; do
grep -q $ip /tmp/$varnish.ips
if [[ $? -eq 0 ]]; then
echo "$vhost $ip $varnish"
found=1
break;
fi
done
if [ $found -eq 0 ]; then
echo "$vhost $ip ERROR NOT FOUND"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment