Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

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.

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

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 <user>:<pass> https://<host>/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 <user>:<admin> https://<host>/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 <user>:<pass> https://<host>/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.

1
Comments on this Answer
Comment made 1 month ago by Joel Newton 401

Thanks, Satoshi. I appreciate the thoroughness of your answer.

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

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.

0
Comments on this Answer
Comment made 1 month ago by Joel Newton 401

Thanks. I wonder if the huge difference in performance is because the individual with the 2500 virtuals is using my PowerShell module to query iControlREST and the PS module expands all subcollections. It would be interesting to compare performance in the module of just the one GET query without expanding the subcollections against how it currently works.

0
Comment made 3 weeks ago by Joel Newton 401

This turned out to be correct. Naturally, the performance difference between making 1 call to get 2500 virtuals and 2500 calls to get 2500 subcollections is significant.

0