Forum Discussion

nikzin_341815's avatar
nikzin_341815
Icon for Nimbostratus rankNimbostratus
Dec 07, 2017

tmsh command for ltm policies in use

Hello community, i am searching a tmsh command which list me all virtual servers where a special ltm policy is attached. I could not find the right command. Is there any idea ? Thank you, Nick

 

2 Replies

  • i am searching a tmsh command which list me all virtual servers where a special ltm policy is attached.

    quick one could be tmsh list ltm virtual one-line |grep

    [root@bip1a:Active:In Sync] config  tmsh list ltm virtual one-line |grep asm_auto_l7_policy__baz
    ltm virtual baz { destination 10.200.155.165:80 ip-protocol tcp mask 255.255.255.255 policies { asm_auto_l7_policy__baz { } } pool foo profiles { ASM_wibble-policy { } http { } tcp { } websecurity { } } source 0.0.0.0/0 source-address-translation { type automap } translate-address enabled translate-port enabled vs-index 3 }
    

    if you like scripting, you may try something like this:

    [root@bip1a:Active:In Sync] config  tmsh list ltm virtual policies |awk '/ltm virtual/ {printf "\n"} {printf "%s",$0} END {printf "\n"}' |tr -d '{}' |tr -s ' ' |grep asm_auto_l7_policy__baz
    ltm virtual baz policies asm_auto_l7_policy__baz
    
  • Something like this may help:

     

    you have an ltm policy called "policy1"

     

    root@(F5Lab)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm policy one-line

     

    ltm policy policy1 { controls { forwarding } last-modified 2017-12-20:16:35:31 requires { http } rules { tt { actions { 0 { http-reply redirect location http://www.google.com } } conditions { 0 { http-uri path values { /test } } } } } status published strategy first-match }

     

    Now search "policy1" across all VSs:

     

    root@(F5Lab)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual one-line | grep policy1

     

    ltm virtual Test_DVM { destination 10.100.100.100:https ip-protocol tcp mask 255.255.255.255 policies { policy1 { } } pool Pool_DVM profiles { analytics { } clientssl { context clientside } http { } tcp { } tcp-analytics { } } source 0.0.0.0/0 source-address-translation { type automap } translate-address enabled translate-port enabled vs-index 3 }