I am setting up an Application Monitor for our KEMP Load Balancer. It's not enough to add the IPs for the Virtual Servers with ICMP, because those will ping as Up, even when the VS is reporting down in Kemp. I've been trying to use PowerShell to get the status of a VS.
$RemServer = "xxx.xxx.xxx.xxx"
$IP = "xxx.xxx.xxx.xxx"
import-module kemp.loadbalancer.powershell
$status = (Get-VirtualService -VirtualService $IP -Protocol tcp -port 443 -LoadBalancer $RemServer).Status
echo ($?)
echo "Status Result"
echo $status
if ($status -ne "Up") {
exit 1
}
else {
exit 0
}
If I run the script in Powershell ISE on the Orion Server itself it works because the Kemp.LoadBalancer.PowerShell module is loaded on the Orion it works as intended:
True
Status Result
Up
But in Application Monitor using the Windows PowerShell Monitor, I get the Output Result:
Output: ==============================================
False
Status Result
Errors: ==============================================
import-module : The specified module 'kemp.loadbalancer.powershell' was not loaded because no valid module file was found in any module directory.
At line:8 char:5
+ import-module kemp.loadbalancer.powershell
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (kemp.loadbalancer.powershell:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Get-VirtualService : The term 'Get-VirtualService' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:16 char:12
+ $status = (Get-VirtualService -VirtualService $IP -Protocol tcp -port 443 -LoadB ...
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-VirtualService:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
To Troubleshoot I've already:
- checked $env:PSModulePath and it includes the path to the Kemp.LoadBalancer.Powershell
- checked my PS Version - which is at 4.0