Forum Discussion
Sep 11, 2015
This one-liner will dump all virtual servers and the associated iRules:
curl -sk -u admin:admin -H "Content-Type: application/json" -X GET "https://localhost/mgmt/tm/ltm/virtual" | \
grep -Eo '("name":"[^,]+|"rules":[^]]+"\])' | tr '\n' ';' | sed -r 's/$/\n/; s/;("name")/\n\1/g' | sed -r 's/;$//g'
Output looks i.e. as follows:
"name":"vs_51";"rules":["/Common/rule_remove_xff","/Common/rule_plaintext"]
"name":"vs_52";"rules":["/Common/rule_remove_xff"]
"name":"vs_53"
"name":"vs_54";"rules":["/Common/rule_plaintext"]
If you filter the output i.e. by using grep or awk for a specific iRule (i.e. "rule_remove_xff") you can expect the following output containing the relevant virtual server names only:
curl -sk -u admin:admin -H "Content-Type: application/json" -X GET "https://localhost/mgmt/tm/ltm/virtual" | grep -Eo '("name":"[^,]+|"rules":[^]]+"\])' | tr '\n' ';' | sed -r 's/$/\n/; s/;("name")/\n\1/g' | sed -r 's/;$//g' | awk -F ';' '/rule_remove_xff/ {print $1}'
"name":"vs_51"
"name":"vs_52"