Forum Discussion
Add an iRule to multiple virtual servers
I am looking for a script to add/apply an irule to a list of virtual servers, or virtual servers that contain "www" in the name.
Thanks.
19 Replies
- Kevin_Stewart
Employee
Hmm, that's what I expected it to look like. Let's work through this iteratively then.
tmsh list /ltm virtual |grep "ltm virtual"That should give you something like this:
ltm virtual vip_oid.s2boss.corp.xxxxxxxxxxxxxxx.com {If you see several lines that look something like this, then add the AWK back in:
tmsh list /ltm virtual |grep "ltm virtual" |awk -F" " '{ print $3 }'The idea here is that you're taking this returned line, splitting it on the empty space, and extracting the third element, which should be the VIP name. Give that a try.
- willsweeper_131
Nimbostratus
I tried, but nothing was returned, just a blinking cursor on the next line. I then tried the same command on another ltm running version 11, got the output as expected.
- Kevin_Stewart
Employee
Well that's just odd. I just spun up a v10 system and DID see results. Are you doing this from the Bash shell, or from within TMSH? What happens when you do this?
tmsh list /ltm virtual |grep "ltm virtual" - willsweeper_131
Nimbostratus
I used putty to SSH to the LTM, then ran the command in there. The LTM is running version 10.2.4. I tried the above command, nothing returned. If I run it without "grep "ltm virtual"", then I got all the virutal servers. How did you run the command on yours?
- Kevin_Stewart
Employee
So weird. This is just Linux Bash command line stuff. I tested with a 10.2.4 system as well, and using the Bash shell (not TMSH). What happens if you just grep a single word:
tmsh list /ltm virtual |grep ltm - willsweeper_131
Nimbostratus
same thing.
Hi!
You COULD do some old fasioned stone age excel "magic" too. 🙂
- Select the virtual server list/table in the Web UI
- Copy it to Excel
- You get a column with only virtual server names, remove the other columns.
- Filter the VIP name column for www.
Assuming that your VIP name column is A, input this in column B:
="tmsh modify /ltm virtual " & A1 & " rules { test-rule }"Autofill the B column and then you're done. 🙂
/Patrik
- JG
Cumulonimbus
I ran the following on a v11.3.0 box:
tmsh list ltm virtual Display all 113 items? (y/n) yand then it displayed nothing. Using "/ltm" produced the same result. (Side question: What does "/" really mean here?)
Is there a bug current for this?
(The same command works in v10.2.4.)
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com