Forum Discussion

Joel_Newton's avatar
Mar 20, 2019

Use iControlREST to find a virtual server by IP address

Is there any way to use iControlREST to search for a virtual server by IP address, that doesn't involve returning all virtual servers and filtering the results? There's an individual using my LTM PowerShell module who has 2500 virtual servers and they need to search them by IP address. Currently it's taking up to 3 hours for results. Thanks.

 

2 Replies

  • You need to get all the virtuals and filter on the client side. Yes, it may take some time to generate and transfer 2,500 virtuals information, but you can trim the amount of data (slightly). The following iControl REST call uses the tmsh

    destination
    option to show only the destination addresses along with some other properties.

    curl -sku : https:///mgmt/tm/ltm/virtual?options=destination
    

    To further trim, use the

    $select
    query option (although it does not reduce the amount of effort on the BIG-IP side, it reduces the amount of traffic on the wire). The following example gets the destination addresses/ports and the virtual names:

    curl -sku : https:///mgmt/tm/ltm/virtual?options=destination\&\$select=destination,or,fullPath
    

    Let us know if the call reduced the execution time.

    Also, check how long it would take for the equivalent tmsh command to complete: e.g.,

    time tmsh list ltm virtual destination
    . If it also takes 3 hours, then the system is either too busy or does not have enough resources to handle the request in timely manner, not because of limitations on iControl REST framework.

    Another option is to run Unix

    grep
    against
    /config/bigip.conf
    for specific virtual destinations: e.g.,

    curl -sku : https:///mgmt/tm/util/bash \
      -X POST -H "Content-type: application/json" \
      -d "{\"command\":\"run\", \"utilCmdArgs\": \"-c '/tmp/sat 172.16.10.30:80'\"}" | 
      python -m json.tool | grep commandResult | sed 's/\\n/\n/g'
    

    where

    /tmp/sat
    is

    !/bin/bash
    grep -A 4 'ltm virtual ' /config/bigip.conf | egrep 'virtual|destination' | grep -B 1 $1
    

    (you can directly put the series of greps in the iControl REST call itself but escaping the nested quotes properly would be fairly cumbersome).

    I know. It does look ugly.

  • P.S. I measured the performance of iControl REST GET against 2,500+ virtuals on my box and it took me only 3s. The returned json object is 3 MB in size. I don't know why it takes 3 hours in your environment.