Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
When a Website is in HA (High Availability) mode, the Website HTTP status code may differ from a server to another if one or multiple servers are experiencing problems. These failures may not be noticed if the frontal Load Balancer have detected them and initiated a failover of the traffic by excluding the faulty servers from the Load Balancing pool. This “hides” the problems so that customers do not notice the failure but the Middleware administrator should be aware about the status change so that he can recover the failure.
This Wiki article shares a way to get the HTTP status code for a Website running on a specific Web server. It allows Middleware administrators to check the health status of Websites on the servers where they are running and can be updated to introduce an automatic mail notification and recovery actions.
To get the HTTP status code for a Website running on a specific Web server, all you need are:
- Download Send-TcpRequest.ps1 Powershell script: http://www.leeholmes.com/blog/2009/10/28/scripting-network-tcp-connections-in-powershell/
- Run the Powershell script below: You will update the following variable values:
- servername: You need to replace it with your server name (FQDN or NetBIOS name)
- hostname: You will need to replace it with the Website DNS name
- port: You will need to replace it to the HTTP port if you are not using the standard one
- path: You will need to replace it to the path you need if you need to check a specific path (Example: /home/ will check
http://website01.contoso.com/home/
)
#################variables################# $servername = "Server1.contoso.com" $hotstname = "website01.contoso.com" $port = 80 ########################################### #################Main###################### try { $http = @" GET $path HTTP/1.1 Host:$hotstname `n`n "@ $httpanswer = $http | .\Send-TcpRequest.ps1 $servername $port [int]$httpanswer.Substring(9,3) } catch { "An exception occurred when executing the script" } |
Remark: The script should be launched from the folder where Send-TcpRequest.ps1 resides.
By running the script, it should provide you with the HTTP status code: