Forum Discussion
list pools a node is in via tmsh
before i write a wrapper script for tmsh does anyone know if there's a simple way to find out what pools a single member is in?
the prompt was getting in the way of the remainder of the commands executing. to combat i did this:
echo y | tmsh list ltm pool|grep -B 20 10.5.72.109 | grep "ltm pool"|awk '{print $3}'
works great now!
- What_Lies_Bene1Cirrostratus
Something like this should do the trick;
list ltm pool | grep -B 20 x.x.x.x | grep ltm pool
The -B 20 specifies the display of twenty 'lines' of output prior to the match for x.x.x.x. If you have pools with many members you may want to increase the value. Each node in a pool takes three lines, each pool name takes 2. So 20 should suffice for pools with up to six members but of course beware that the value isn't too high either else you'll potentially see pool names that the node isn't a member of.
- What_Lies_Bene1Cirrostratus
OK, I've tested further using this to show line numbers and whatever the -B value grep seems smart enough not to duplicate matches;
list ltm pool | grep -B 30 x.x.x.x | grep -n ltm pool
- NikCirrus
the prompt was getting in the way of the remainder of the commands executing. to combat i did this:
echo y | tmsh list ltm pool|grep -B 20 10.5.72.109 | grep "ltm pool"|awk '{print $3}'
works great now!
Nik - I marked this as the solution to your original query. Seems right.
If not...unselect this one.
OR
If you think there are other replies that also qualify as part of the solution (in this post) you can mark them too.thanks for being crucial to the health of our community.
Lief
- phuzzieNimbostratus
I would recommend using the "one-line" parameter to help ensure you don't get false positives due to the vagaries of configuration lengths.
tmsh -q list ltm pool one-line | grep -E '($node_hostname|$node_ip)' | awk '{ print $3 }'
- isuru_jayaweeraNimbostratus
Great!!! this works in tmsh.
list ltm pool one-line | grep "address 192.168.10.12"
- Josh_Jacobson_4Altostratus
you can also use the "display-threshold" preference to stop tmsh from giving you the "display all items" prompt (set to some reasonably large number for your environment):
modify cli preference display-threshold 500
- NikCirrusi think tmsh's confirmation is getting in the way of this executing. when i pipe the output to grep it hangs indefinitely. here's an example of my confirmation:
- What_Lies_Bene1CirrostratusLooks good, what does the awk command do?
- NikCirrusi used it to print out the third parameter, which is the pool name.
- What_Lies_Bene1CirrostratusAh OK, nice. Thanks
- nitassEmployeethe prompt was getting in the way of the remainder of the commands executing.
just in case if you have not yet seen this tmsh option.
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