Have some code. Share some code.
Showing results for 
Search instead for 
Did you mean: 
Custom Alert Banner

Problem this snippet solves:

This is a simple cli script used to collect all the virtual-servers name, its destination created in a server or ltm server.

A sample output would be like below,


How to use this snippet:

This is similar to my other share -

Login to the GTM/DNS, create your script by running the below commands and paste the code provided in snippet,

create cli script gtm-vs

Delete the proc blocks, so it looks something like below,

create script gtm-vs {

and paste the code provided in the snippet.

Note: When you paste it, the indentation may be realigned, it shouldn't cause any errors, but the list output would show improperly aligned.

Feel free to delete the tab spaces in the code snippet & paste it while creating, so indentation is aligned properly.

And you can run the script like below,

tmsh run cli script gtm-vs > /var/tmp/gtm-vs-output.csv

And get the output from the saved file, open it on excel. Format it & use it for audit & reporting.

cat /var/tmp/gtm-vs-output.csv

Feel free to add more elements as per your requirements.

Code :

proc script::run {} {
puts "Server,Virtual-Server,Destination"
foreach { obj } [tmsh::get_config gtm server] {
set server [tmsh::get_name $obj]
foreach { vss } [tmsh::get_config gtm server $server virtual-servers] {
set vs_set [tmsh::get_field_value $vss virtual-servers]
foreach vs $vs_set {
set vs_name [tmsh::get_name $vs]
puts $server,$vs_name,[tmsh::get_field_value $vs destination]

Tested this on version:

Community Manager
Community Manager

Hey @jaikumar_f5 I featured this article on today's Top 5 Live Stream! Thanks for this contribution!

It's an honor for featuring my handy useful code 😀 You called it right on the stream, these codes come real handy when reporting, auditing, NAT'ing comes into play.

Thanks @buulam - for recognising the efforts.

Version history
Last update:
‎23-Dec-2021 01:59
Updated by: