Forum Discussion
Problem about Export imformation to Excel
- Mar 21, 2023
i modify and optimize the tmsh script, it reports pool_name, pool_members_list(members is addr:port or addr.port), the disadvantage is when use [tmsh::get_status /ltm virtual $VS_name], it will lose the route domain-id, such as %1,%2 and so on.
script support AS3 and Common or other partition
cli script virtual-details { proc script::init {} { } proc check_vs {partition {partition_folder ""}} { if { $partition_folder eq "" } { tmsh::cd /$partition } else { tmsh::cd /${partition}/${partition_folder} } foreach { obj } [tmsh::get_config ltm virtual all-properties] { set VS_name [tmsh::get_name $obj] set VSname "" foreach { VSip } [tmsh::get_status /ltm virtual $VS_name] { set VSIIP [tmsh::get_field_value $VSip "destination"] } set poolname [tmsh::get_field_value $obj "pool"] set profiles [tmsh::get_field_value $obj "ip-protocol"] set persist [lindex [lindex [tmsh::get_field_value $obj "persist"] 0] 1] if { $poolname != "none" } { set poolconfig [tmsh::get_config /ltm pool $poolname all-properties] foreach { poolinfo } $poolconfig { set pool_lb [tmsh::get_field_value $poolinfo "load-balancing-mode"] set pool_monitor [tmsh::get_field_value $poolinfo "monitor"] if { [catch { set member_name [tmsh::get_field_value $poolinfo "members" ]} err] } { set pool_member $err puts "$VS_name,$VSIIP,$profiles,$pool_lb,$persist,$poolname,$addr,$port,$pool_monitor" } else { set pool_member {} foreach mem [tmsh::get_status /ltm pool $poolname members] { foreach poolmember [tmsh::get_field_value $mem "members"] { set addr [tmsh::get_field_value $poolmember "addr"] set port [tmsh::get_field_value $poolmember "port"] if { $addr contains "." } { lappend pool_member "$addr:$port" } else { lappend pool_member "$addr.$port" } } } # puts "--------" # puts "$pool_member" # puts "$VS_name,$VSIIP,$profiles,$pool_lb,$persist,$poolname,$pool_member,$pool_monitor" } } puts "$VS_name,$VSIIP,$profiles,$pool_lb,$persist,$poolname,$pool_member,$pool_monitor" } else { puts "$VS_name,$VSIIP,$profiles,none,$persist,$poolname,none,none" } } } proc script::run {} { puts "VServer_name,VServer_IP:Port,Protocol,Load_Balance,Persist_Method,PooL_Name,PooL_Members,Monitor_Protocol" foreach all_partitions [tmsh::get_config auth partition] { # set partition "[lindex [split $all_partitions " "] 2]" set partition "[tmsh::get_name ${all_partitions}]" tmsh::cd /$partition if { [tmsh::get_config /sys folder] eq "" } { check_vs $partition } else { foreach { partition_folder_config } [tmsh::get_config /sys folder] { set partition_folder_name [tmsh::get_name ${partition_folder_config}] if { $partition eq "Common" } { check_vs $partition break } else { check_vs ${partition} ${partition_folder_name} } } } } } proc script::help {} { } proc script::tabc {} { } }
i modify and optimize the tmsh script, it reports pool_name, pool_members_list(members is addr:port or addr.port), the disadvantage is when use [tmsh::get_status /ltm virtual $VS_name], it will lose the route domain-id, such as %1,%2 and so on.
script support AS3 and Common or other partition
cli script virtual-details {
proc script::init {} {
}
proc check_vs {partition {partition_folder ""}} {
if { $partition_folder eq "" } {
tmsh::cd /$partition
} else {
tmsh::cd /${partition}/${partition_folder}
}
foreach { obj } [tmsh::get_config ltm virtual all-properties] {
set VS_name [tmsh::get_name $obj]
set VSname ""
foreach { VSip } [tmsh::get_status /ltm virtual $VS_name] {
set VSIIP [tmsh::get_field_value $VSip "destination"]
}
set poolname [tmsh::get_field_value $obj "pool"]
set profiles [tmsh::get_field_value $obj "ip-protocol"]
set persist [lindex [lindex [tmsh::get_field_value $obj "persist"] 0] 1]
if { $poolname != "none" } {
set poolconfig [tmsh::get_config /ltm pool $poolname all-properties]
foreach { poolinfo } $poolconfig {
set pool_lb [tmsh::get_field_value $poolinfo "load-balancing-mode"]
set pool_monitor [tmsh::get_field_value $poolinfo "monitor"]
if { [catch { set member_name [tmsh::get_field_value $poolinfo "members" ]} err] } {
set pool_member $err
puts "$VS_name,$VSIIP,$profiles,$pool_lb,$persist,$poolname,$addr,$port,$pool_monitor"
} else {
set pool_member {}
foreach mem [tmsh::get_status /ltm pool $poolname members] {
foreach poolmember [tmsh::get_field_value $mem "members"] {
set addr [tmsh::get_field_value $poolmember "addr"]
set port [tmsh::get_field_value $poolmember "port"]
if { $addr contains "." } {
lappend pool_member "$addr:$port"
} else {
lappend pool_member "$addr.$port"
}
}
}
# puts "--------"
# puts "$pool_member"
# puts "$VS_name,$VSIIP,$profiles,$pool_lb,$persist,$poolname,$pool_member,$pool_monitor"
}
}
puts "$VS_name,$VSIIP,$profiles,$pool_lb,$persist,$poolname,$pool_member,$pool_monitor"
} else {
puts "$VS_name,$VSIIP,$profiles,none,$persist,$poolname,none,none"
}
}
}
proc script::run {} {
puts "VServer_name,VServer_IP:Port,Protocol,Load_Balance,Persist_Method,PooL_Name,PooL_Members,Monitor_Protocol"
foreach all_partitions [tmsh::get_config auth partition] {
# set partition "[lindex [split $all_partitions " "] 2]"
set partition "[tmsh::get_name ${all_partitions}]"
tmsh::cd /$partition
if { [tmsh::get_config /sys folder] eq "" } {
check_vs $partition
} else {
foreach { partition_folder_config } [tmsh::get_config /sys folder] {
set partition_folder_name [tmsh::get_name ${partition_folder_config}]
if { $partition eq "Common" } {
check_vs $partition
break
} else {
check_vs ${partition} ${partition_folder_name}
}
}
}
}
}
proc script::help {} {
}
proc script::tabc {} {
}
}
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