Created
October 22, 2012 18:43
-
-
Save drsnyder/3933307 to your computer and use it in GitHub Desktop.
Where is that vip?
This file contains hidden or 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
| #!/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