Forum Discussion

Mubasher_Sultan's avatar
Mubasher_Sultan
Icon for Nimbostratus rankNimbostratus
Jan 14, 2014

How to use Grep command to identify the particular VS and their state?

Hi Folks,

 

I want to identify the VS servers having the string e.g., TO2 and their "Availability" or "State"

 

I am using the below command

 

show /ltm virtual all-properties | grep -i "to2" ---> It works fine... show /ltm virtual all-properties | grep -i to2 | grep Availability ---> Doesn't work show /ltm virtual all-properties | grep -i to2 | grep State ---> Doesn't work

 

Please help or any advise...

 

5 Replies

  • grep works on a linefeed boundary, whereas the tmsh output contains multiple lines.

    While you can't do this in tmsh since the grep doesn't support -A there, you could use something like this on the command line:

    tmsh show ltm virtual|grep ^Ltm:: -A5|grep -e 'Ltm::\|\ \ Availability\|\ \ State'

    here's me running that:
    [root@snk-5:Active:Standalone] config  tmsh show ltm virtual|grep ^Ltm:: -A5|grep -e '^Ltm::\|^\ \ Availability\|^\ \ State'
    Ltm::Virtual Server: next4p81  
      Availability     : unknown   
      State            : enabled   
    Ltm::Virtual Server: next4p82  
      Availability     : unknown   
      State            : enabled   
    Ltm::Virtual Server: next6p81  
      Availability     : unknown   
      State            : enabled   
    Ltm::Virtual Server: next6p82  
      Availability     : unknown   
      State            : enabled   
    [root@snk-5:Active:Standalone] config  
    
    • Sreenivasa_P's avatar
      Sreenivasa_P
      Icon for Nimbostratus rankNimbostratus

      how to read before and after line like in v10 we have command -a5 or -b5 but its not working in v11

       

    • Sreenivasa_P's avatar
      Sreenivasa_P
      Icon for Nimbostratus rankNimbostratus

      how to read before and after lines like in v10 we have command -a5 or -b5 but its not working in v11

       

  • That's cool :)

     

    But, please let me know that how to filter some of the VS having string e.g., "to2" and display as above but not all...

     

    Regards, Mubasher

     

  • Substitute where I use ^Ltm:: with "to2" (in both greps) to accomplish that.

     

    Here's my example where I've modified the grep statements to show only virtuals with "p82" in the name: [root@snk-5:Active:Standalone] config tmsh show ltm virtual|grep p82 -A5|grep -e 'p82|\ \ Availability|\ \ State'

     

    Ltm::Virtual Server: next4p82

     

    Availability : unknown

     

    State : enabled

     

    Ltm::Virtual Server: next6p82

     

    Availability : unknown

     

    State : enabled

     

    [root@snk-5:Active:Standalone] config