Forum Discussion
Kevin_Stewart
Sep 11, 2015Employee
Child objects don't reference their parents, so you'd necessarily have to loop through each parent VIP to see if a specific rule was applied. So while I'm quite certain there's an easier way to do this, I cooked up a little Bash script to loop through all of the VIPs in /Common and find a given rule. Tweak as needed.
!/bin/bash
find and loop through all of the VIPs
for vip in `curl -sk -u 'admin:admin' -H "Content-Type: application/json" -X GET "https://x.x.x.x/mgmt/tm/ltm/virtual" |grep -o '\"name\":\"[^"]*' |awk -F"\"" '{ print $4 }'`
do
find the rules associated with this VIP
rule=`curl -sk -u 'admin:admin' -H "Content-Type: application/json" -X GET "https://x.x.x.x/mgmt/tm/ltm/virtual/$vip" |grep -o '\"rules\":[^,]*' |awk -F":" '{ print $2 }'`
specify here which rule you're looking for (glob match)
if [[ $rule == *"redirect"* ]]
then
if rule is found echo some text
echo "$vip contains $rule"
fi
done