Forum Discussion
Hi Gabe,
I am working on something similar to diff VS configs across a pair of LTMs for a migration I'm working on, and I found this post so I thought I'd share - this small bash script lives directly on the LTM, but since it will work with remote hosts, it can live anywhere that can execute bash scripts.
vsdiff.sh requires two arguments, vs1 and vs2 to compare. If the script finds a colon in either of the arguments, it will parse the left hand side out as a host, and pass the whole thing through ssh. So if I call it like this: "./vsdiff.sh vs_yayf5 vs_doubleyay" it will assume both are local and just run them through tmsh, but I can also call it this way: "./vsdiff.sh vs_yayf5 ltm02:vs_someremotevs" (it passes the host part directly to ssh, so you can do user@host:vsname as well).
Of course, standard disclaimer applies here (ymmv, "no warranty or guarantee of fit for any purpose is expressed or implied", don't run this in production without testing it in your environment first!! yadda yadda yadda ... ) - hope this is helpful!
-Josh
!/bin/bash
Make sure we have inputs and let 'er rip
[[ $1 && $2 ]] || { echo Usage: vsdiff.sh [host:]vs1 [host:]vs2; exit; }
echo Comparing [$1] and [$2] ...
do this for both VSs
for i in 1 2; do
figure out if we're local or remote
if [[ ${!i} =~ .*:.* ]]; then
h=$(echo ${!i} | cut -f1 -d':')
v=$(echo ${!i} | cut -f2 -d':')
else
h=LOCAL
v=${!i}
fi
grab the configs into a couple temp files
t=$(mktemp)
declare tmp$i=$t
cmd="tmsh -q list ltm virtual $v"
[[ $h != LOCAL ]] && cmd="ssh $h $cmd 2>&1"
$cmd 2>&1 > $t
done
diff the configs side by side and clean up
diff -y $tmp1 $tmp2
rm $tmp1 $tmp2