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.
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 failover
and 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.
Thanks Amit & Joe
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.” }
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
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." }