Forum Discussion

Jozef_Hamar's avatar
Jozef_Hamar
Icon for Altostratus rankAltostratus
Sep 29, 2014

How to list virtual servers based on some properties, like destination/pool/profile used

Hi there,

I would like to ask, if I can use the tmsh "list ltm virtual" command to list all virtual servers which have some specific value assigned.

E.g.

  • "Tell me which virtual servers do listen on VIP A.B.C.D"
  • "Tell me which virtual servers use the pool my_pool"
  • "Tell me which virtual servers use persistence profile src_addr"

So far I'm using grep:

list ltm virtual destination | grep -B 1 A.B.C.D

or something similar for pools/profiles, etc...

Thank you.

3 Replies

  • Kevin_K_51432's avatar
    Kevin_K_51432
    Historic F5 Account

    Hi Jozef, That's the way to find specific values. Filter for something which delimits the output so you don't accidentally mix configuration from two different objects. You can add as many values as you like using |. For example:

     list ltm virtual all | grep 'ltm virtual\|my_pool'
    ltm virtual my_vip_one {
        pool my_pool
    ltm virtual my_vip_three {
        pool my_pool
    ltm virtual my_vip_two {
        pool my_pool
    
     list ltm virtual all | grep 'ltm virtual\|my_source'
    ltm virtual my_vip_one {
            my_source {
    ltm virtual my_vip_three {
            my_source {
    ltm virtual my_vip_two {
            my_source {
    
     list ltm virtual all | grep 'ltm virtual\|1.2.3'
    ltm virtual my_vip_one {
        destination 1.2.3.4:https
    ltm virtual my_vip_three {
        destination 1.2.3.6:https
    ltm virtual my_vip_two {
        destination 1.2.3.5:https
    
     list ltm virtual all | grep 'ltm virtual\|my_source\|1.2.3.4'
    ltm virtual my_vip_one {
        destination 1.2.3.4:https
            my_source {
    
    

    Hope this is helpful, Kevin

  • Hi Jozef, there is a tmsh script in the codeshare you can load that allows you to search the config by object name. Example on my system.

    [root@ltm1:Active:Standalone] config  tmsh findconf rule.rest_api
    found 2 matches in 5180 configuration objects
    ltm rule : rule.rest_api
    ltm virtual : vip.iruler_backend
        rules: rule.rest_api
    
  • Thanks guys.

    I was sort of hoping I can achieve that without external filering using grep or another Perl script. Don't get me wrong, I love scripting. It's just that I was curious if I'm not using grep for something already implemented in the tmsh itself.

    It's like using

    cat file | grep string
    

    instead of using

    grep string file
    

    Anyway, thank you for your answers...