admin管理员组文章数量:1363220
I am using powershell F5-LTM module to connect to F5 and get data
$secpasswd = ConvertTo-SecureString "1234567890" -AsPlainText -Force
$MyLTM_IP = "12.18.10.8"
$mycreds = New-Object System.Management.Automation.PSCredential "User_Auto", $secpasswd
$session = $null
#Create an F5 session
$session = New-F5Session -LTMName $MyLTM_IP -LTMCredentials $mycreds -PassThru
there are details like below I am able to fetch for the virtual server
"Vip_Name","Vip_IP","Pool_Name","Node_Name","Node_IP"
But there is a parameter call Availability which I am not able to find. attached image for reference
below is the rest of the code
$vips = Get-VirtualServer -F5Session $session -Name "VS_224_PPR_50003"
$report = @()
foreach($vip in $vips) {
$Vip_Name = $vip.Name
$inputString = $vip.destination
$vip_virtual_addr = $inputString -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}' | Out-Null
$vip_ip_addr = $matches[0]
$vippool = $vip.pool
$vippool_name = $vippool.Name
$get_pool_node = Get-PoolMember -F5Session $session -PoolName $vippool
$firstNode = $true
foreach($nods in $get_pool_node) {
$Nodes_name = ($nods.name) -split ':' | Select-Object -First 1
$Nodes_ip = $nods.Address
if ($firstNode) {
# Add the data to the array for the first node
$report += [PSCustomObject]@{
Vip_Name = $Vip_Name
Vip_Status = "available" # Assuming status is available, adjust as needed
Vip_IP = $vip_ip_addr
Pool_Name = $vippool_name
Node_Name = $Nodes_name
Node_IP = $Nodes_ip
}
$firstNode = $false
} else {
# Add the data to the array for subsequent nodes
$report += [PSCustomObject]@{
Vip_Name = ""
Vip_Status = ""
Vip_IP = ""
Pool_Name = ""
Node_Name = $Nodes_name
Node_IP = $Nodes_ip
}
}
}
}
# Export the data to a CSV file
$report | Export-Csv -Path "D:\vip_report.csv" -NoTypeInformation
Please let me know how can I get the data
I am using powershell F5-LTM module to connect to F5 and get data
$secpasswd = ConvertTo-SecureString "1234567890" -AsPlainText -Force
$MyLTM_IP = "12.18.10.8"
$mycreds = New-Object System.Management.Automation.PSCredential "User_Auto", $secpasswd
$session = $null
#Create an F5 session
$session = New-F5Session -LTMName $MyLTM_IP -LTMCredentials $mycreds -PassThru
there are details like below I am able to fetch for the virtual server
"Vip_Name","Vip_IP","Pool_Name","Node_Name","Node_IP"
But there is a parameter call Availability which I am not able to find. attached image for reference
below is the rest of the code
$vips = Get-VirtualServer -F5Session $session -Name "VS_224_PPR_50003"
$report = @()
foreach($vip in $vips) {
$Vip_Name = $vip.Name
$inputString = $vip.destination
$vip_virtual_addr = $inputString -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}' | Out-Null
$vip_ip_addr = $matches[0]
$vippool = $vip.pool
$vippool_name = $vippool.Name
$get_pool_node = Get-PoolMember -F5Session $session -PoolName $vippool
$firstNode = $true
foreach($nods in $get_pool_node) {
$Nodes_name = ($nods.name) -split ':' | Select-Object -First 1
$Nodes_ip = $nods.Address
if ($firstNode) {
# Add the data to the array for the first node
$report += [PSCustomObject]@{
Vip_Name = $Vip_Name
Vip_Status = "available" # Assuming status is available, adjust as needed
Vip_IP = $vip_ip_addr
Pool_Name = $vippool_name
Node_Name = $Nodes_name
Node_IP = $Nodes_ip
}
$firstNode = $false
} else {
# Add the data to the array for subsequent nodes
$report += [PSCustomObject]@{
Vip_Name = ""
Vip_Status = ""
Vip_IP = ""
Pool_Name = ""
Node_Name = $Nodes_name
Node_IP = $Nodes_ip
}
}
}
}
# Export the data to a CSV file
$report | Export-Csv -Path "D:\vip_report.csv" -NoTypeInformation
Please let me know how can I get the data
Share Improve this question asked Apr 1 at 9:46 SnehasishSnehasish 257 bronze badges 1 |1 Answer
Reset to default 0updating...from the iControl REST json response, you need to get the nested stats to see the availability details. Not exactly sure how that manifests in the powershell module, but the request is:
https://x.x.x.x/mgmt/tm/ltm/virtual/your-virtual-name/stats
And the resulting json payload (stripped down to what you care about):
{
"entries": {
"https://localhost/mgmt/tm/ltm/virtual/your-virtual-name/stats": {
"nestedStats": {
"entries": {
"status.availabilityState": {
"description": "offline"
},
"status.enabledState": {
"description": "enabled"
},
"status.statusReason": {
"description": "The children pool member(s) are down"
}
}
}
}
}
}
本文标签: Get virtual server availability status F5 using powershellStack Overflow
版权声明:本文标题:Get virtual server availability status F5 using powershell - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743896055a2557806.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
$vip |ConvertTo-Json
or$nods |ConvertTo-Json
might make it easier to inspect the returned data visually – Mathias R. Jessen Commented Apr 1 at 10:44