Forum Discussion
Need help to identify which is the active load balancer from PowerShell cmdlets
Need help to identify which is the active load balancer from PowerShell cmdlets and also need to know if can initiate a sync from an active load balancer to passive load balancer using PowerShell.
7 Replies
- Amit_Grover_171
Nimbostratus
Hi Sheela,
Not sure about powershell but F5 gives you TMOS shell i.e. TMSH and you can try following.
You can follow below command to check failover details.
show sys failoverand you can follow below article to sync config.
Active-standby-sync-using-tmsh-commands
/Regards Amit Grover
Take a look at the System.Failover.get_failover_state() call. For the device you are making the call on it will return the FailoverState of standby, active, forced offline, offline, or unknown. With PowerShell, you can do something like this (assuming you've initialized the snapin already)
$ (Get-F5.iControl).SystemFailover.get_failover_state();-Joe
Regarding triggering a config sync from one device to the other, look in the System.ConfigSync interface. Look for the synchronize_* methods.
- Sheela_Narayan_
Nimbostratus
Thanks Amit & Joe
- Prabu_MOhan_102
Nimbostratus
This should help identify active standby:-) $Hostname1="F5 Device ip" $Hostname2="F5 Device ip" $Username="Username" $Password="password"
Check and load icontrol Snapin$checkSnapIn = Get-PSSnapIn iControlSnapIn -EA SilentlyContinue If ($checkSnapIn.length -eq 0) { Add-PSSnapIn iControlSnapIn }
Login and Unit Active \Standby check$login = Initialize-F5.iControl -HostName $Hostname1 -Username $Username -Password $Password
if ($login -eq "true") { Write-Host Logged into $Hostname1 F5 successfully.; $ISactive = Get-F5.DBVariable -Name Failover.State | select Value | ft -hide |Out-String
if ( $ISactive.trim() -eq "active") { Write-Host "Device" $Hostname1 is $ISactive.trim(); } else { $login = Initialize-F5.iControl -HostName $Hostname2 -Username $Username -Password $Password if ($login -eq "true") { Write-Host Logged into $Hostname2 F5 successfully.; $ISactive = Get-F5.DBVariable -Name Failover.State | select Value | ft -hide |Out-String Write-Host "Device" $Hostname2 is $ISactive.trim(); if ( $ISactive.trim() -ne "active"){ Write-Host "Something went wrong both servers are not set active"; } }else{ Write-Host "Login in Failed." } }}else { Write-Host "Login in Failed." }
- Joel_Newton
Cirrus
This can also be done via the REST API:
Create your credential object $username = "myusername" $secpasswd = ConvertTo-SecureString "PlainTextPassword" -AsPlainText -Force $f5device = "mydevicename" $mycreds = New-Object System.Management.Automation.PSCredential ($username, $secpasswd) Set the value of the failover page and query it $FailoverPage = "https://$f5device/mgmt/tm/cm/failover-status" $FailoverJSON = Invoke-RestMethod -Method Get -Uri $FailoverPage -Credential $mycreds This is where the failover status is indicated $FailoverJSON.entries.'https://localhost/mgmt/tm/cm/failover-status/0'.nestedStats.entries.status.description - Prabu_MOhan_102
Nimbostratus
Hi ,
Just realised my last post wasn't that good :-).. below if the proper one !
$Hostname1="F5 Device ip" $Hostname2="F5 Device ip" $Username="Username" $Password="password" Check and load icontrol Snapin $checkSnapIn = Get-PSSnapIn iControlSnapIn -EA SilentlyContinue If ($checkSnapIn.length -eq 0) { Add-PSSnapIn iControlSnapIn } Login and Unit Active \Standby check $login = Initialize-F5.iControl -HostName $Hostname1 -Username $Username -Password $Password if ($login -eq "true") { Write-Host Logged into $Hostname1 F5 successfully.; $ISactive = Get-F5.DBVariable -Name Failover.State | select Value | ft -hide |Out-String if ( $ISactive.trim() -eq "active") { Write-Host "Device" $Hostname1 is $ISactive.trim(); } else { $login = Initialize-F5.iControl -HostName $Hostname2 -Username $Username -Password $Password if ($login -eq "true") { Write-Host Logged into $Hostname2 F5 successfully.; $ISactive = Get-F5.DBVariable -Name Failover.State | select Value | ft -hide |Out-String Write-Host "Device" $Hostname2 is $ISactive.trim(); if ( $ISactive.trim() -ne "active"){ Write-Host "Something went wrong both servers are not set active"; } }else{ Write-Host "Login in Failed." } } }else { Write-Host "Login in Failed." }
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