Saturday, March 24, 2012

Server Up/Down via TCP

I am trying to do a server status page. I am having an issue with getting mulitple servers to show status. I have one that replies and that is it. I am using Visual Studio 2005 with VB. I am using the following:

Imports System.IO
Imports System.Drawing
Imports System.Net
Imports System.Net.Sockets

Dim xxxxx as string = " ipaddress"

Dim tcpClient As New Tcpclient

Dim myxxx as ipaddress - ipaddress.parse(XXXX)

then I do a

Try
tcpClient.COnnect(myXXXX, 80)
xxxxtxt.text = "ONLINE"
xxxxtxt.forecolor = system.drawing.color.green
Catch ex As Exception
xxxxtxt.text = "OFFLINE"
xxxxtxt.forecolor = system.drawing.color.red
End Try

Like I said I can only get this to work for one and not the others. Any help would be greatly appreciate. I am open to doing this another way if anyone has one.


Hello,

You could write some code(object) to call WMI and it can show your server status. Follow this example, you will solve your problem.

Listening for WMI Events in ASP.NET Health Monitoring

http://msdn2.microsoft.com/en-us/library/ms178713%28VS.80%29.aspx

0 comments:

Post a Comment