Forum Discussion

MSK_222682's avatar
MSK_222682
Icon for Nimbostratus rankNimbostratus
Feb 24, 2016

Script to export list of Virtual Servers attached with HTTP profiles

Hi,

 

I'm been asked to update all the virtual servers having http profile with logging iRule. Now, in my environment I have thousands of virtuals servers in each BIG IP of APAC/ EMEA / US and therefore it would be laborious process to extract all this information and attach iRule to them.

 

I'm looking for some script (to find virtual servers having http profile) that I can run on LTM which could be exported into excel so as to send that details to CAB meeting in our system and also it would be easy for me to delegate some of the work and to perform check and balance.

 

It would be great if anyone can help me in this.

 

Thanks, Sai

 

3 Replies

  • you could try this, it limits the scope to specifically VSs with 'http' profile name otherwise you may get hits for VSs with http in the VS name or rule name etc..

    tmsh -q -c "list ltm virtual recursive profiles {http} " | awk 'BEGIN {RS="\n}"} !/\ none/ {print}'| grep ^ltm | awk '{print $3}'

  • Save this as an executable script and run it, it should list the VS name, VS IP and pool member IPs.

    cheers

    !/bin/bash
    
     List VSs with 'http' profile name
    
    VS=`tmsh -q -c "list ltm virtual recursive profiles {http} " | awk 'BEGIN {RS="\n}"} !/\ none/ {print}'| grep ^ltm | awk '{print $3}'`
    
     Get pool name for each VS
    
    for all in ${VS}
      do
      POOL=`tmsh -q list ltm virtual $all pool  | awk  '/pool/ {print $2}'`
      DESTINATION=`tmsh -q list ltm virtual $all destination  | awk -F'[ :]' '/destination/ {print $6}'`
    
        if [ "$POOL" != "none" ]
          then
            POOLIP=`tmsh list ltm  pool $POOL members| awk -F '[ :]' -v ORS=", " '/^ +[0-9]/ {print $9; count++ }'`
          else
            POOLIP="-"
        fi
    
    printf "%-45s %-20s %-20s %-s\n" "$all" "$DESTINATION" "$POOLIP"
    done