Yank a Server from NLB when it fails?
It's about 30 minutes from the start of my session on H/A at the SPC. One of the things I talk about in the session is how easy it is to monitor your web servers for failure and yank them from NLB when they do. I've posted the example code below. It's slimmed down greatly to fit in the presentation so I will try to update this later with more robust logic. I'll try to get this in a code block just as soon as I find that the code gadget again.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
HttpStatusCode code = response.StatusCode;
if(code.ToString() != “200”)
ManagementScope NLBScope = new ManagementScope("\\\\" + server + "\\root\\MicrosoftNLB");
ManagementClass NLBClass = new ManagementClass(NLBScope, new ManagementPath("MicrosoftNLB_Node"), null);
foreach (ManagementObject node in NLBClass.GetInstances())