Forum Discussion
list pools a node is in via tmsh
- Oct 29, 2012
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!
I make some modification on the basis, and output the vs-pool-pool_member, like this
[root@lab-1:Active:Standalone] config # sh network-map-output.sh 10.128.1.245
Searching for 10.128.1.245 in LTM config ...
dns_listener (10.128.10.230 on port 53/udp)
Pool: bind_server_pool
---> 10.128.20.11 on port 53
---> 10.128.20.12 on port 53
---> 10.128.20.13 on port 53
p80_virtual1 (10.128.10.20 on port 80/tcp)
Pool: p80_pool_11-12
---> 10.128.20.11 on port 53
---> 10.128.20.12 on port 53
p80_virtual2 (10.128.10.30 on port 80/tcp)
Pool: p80_pool_13-14
---> 10.128.20.13 on port 53
---> 10.128.20.14 on port 80
vs_https_need_to_del (10.242.136.15 on port 443/tcp)
Pool: p80_pool_11-12
---> 10.128.20.11 on port 53
---> 10.128.20.12 on port 53
vs_policy (10.128.10.201 on port any/tcp)
Pool: iRules_pool11
---> 10.128.20.11 on port 53
vs_temp_need_to_del (10.242.136.1 on port 4488/tcp)
Pool: bind_server_pool
---> 10.128.20.11 on port 53
---> 10.128.20.12 on port 53
---> 10.128.20.13 on port 53
============================================================================================
tmsh_mod="tmsh -q"
echo "Searching for $1 in LTM config ... "
vs_list=$( $tmsh_mod list ltm virtual one-line | grep " pool" | awk '{print $3}')
for vs in $vs_list
do
vs_protocol=$($tmsh_mod list ltm virtual $vs | awk '$1=="ip-protocol" {print $2}')
vs_ip_port=$($tmsh_mod list ltm virtual $vs | awk '$1=="destination" {print $2}')
vs_ip=$(echo $vs_ip_port | awk -F: '{print $1}' )
vs_port_name=$(echo $vs_ip_port | awk -F: '{print $2}' )
vs_pool_name=$($tmsh_mod list ltm virtual $vs | awk '$1=="pool" {print $2}')
if [ "$(grep $vs_protocol /etc/services | awk '$1=="'$vs_port_name'" {print $2}')" ]
then
vs_port=$(grep $vs_protocol /etc/services | awk '$1=="'$vs_port_name'" {print $2}')
else
vs_port=$(echo "$vs_port_name/$vs_protocol")
fi
echo "$vs ($vs_ip on port $vs_port)"
pool_member_addr_list=$($tmsh_mod list ltm pool $vs_pool_name | awk '$1=="address" {print $2}' )
echo " Pool: $vs_pool_name"
for pool_member_addr in $pool_member_addr_list
do
pool_member_port_name=$($tmsh_mod list ltm pool $pools_pool | grep $pool_member_addr | grep addr -B1 | awk -F: 'NR==1 {print $2}' | awk ' {print $1}' )
the_name_map_to_port_requirement=$(grep $vs_protocol /etc/services | awk '$1=="'$pool_member_port_name'" {print $2}')
if [ "$the_name_map_to_port_requirement" ]
then
pool_member_port=$(echo $the_name_map_to_port_requirement | awk -F/ '{print $1}')
else
pool_member_port=$(echo $pool_member_port_name)
fi
echo " ---> $pool_member_addr on port $pool_member_port"
done
done
output is giving whole network map. is it possible to filter only one virtual server details?
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