I am trying to do a web page with a network status on it for several apps. I have tried it one way and posted it here but no replies. Any suggestions on how to have it ping a server with many different servers with online if it gets a reply or offline if it gets the time out or cant ping. Any helpe would be appreciated.
Thanks
To simply ping a server it is as simple asMy.Computer.Network.Ping("hostnameOrIp")
It will return true or false.
Cool. What I am trying to do is take that information and put in a page that says Online or Offline. But I have several Servers to do this. Any suggestions? Thanks for replying by the way.
Well, do one ping per server :P The way ping works is that it tries to send small packets to the destinated IP, if the data gets through we have PING! (funny word btw ;-). Things will get a bit different if you want to check if the server answers on specific ports. But just to do ping on several servers is piece of cake:
If My.Computer.Network.Ping("server1") = true
response.write("Online")
else
response.write("Offline")
end ifIf My.Computer.Network.Ping("server2") = true
response.write("Online")
else
response.write("Offline")
end if
I would setup an ArrayList to hold all the servers, then loop through them, ping, and print their status:
Dim arrServersAs New ArrayList()Dim intCountAs IntegerDim strMessageAs StringarrServers.Add("192.168.1.100")arrServers.Add("192.168.1.101")arrServers.Add("192.168.1.102")For intCount = 0To arrServers.Count - 1 strMessage ="Server " &CStr(arrServers(intCount))If My.Computer.Network.Ping(arrServers(intCount))Then strMessage +=" is online"Else strMessage +=" is offline"End If Response.Write(strMessage)Next
Hope this helps! Please do not forget to mark the helpful post(s) as Answer so future readers know what solved your problem.
MY is requiring declaration and where is it to be declared?
IfMy.Computer.Network.Ping(arrServers(intCount))Then
Are you using ASP 1.x or 2.0?
2.0
Well that is really strange, becuase My works just fine and I have tested it.
It should be an automatically inherited namespace. I guess the only thing I can suggest you to try it to put
Imports My
at the top of the code behind.
Also, are you using C#?
Heck no. I can't stand anything to do with C. LOL I am using VB.
It works to an extent. I have about 14 servers I do this and I want to be able to do:
XXX Online or XXX Offline
YYY Online or YY Offline
Right now it is accounting all of the being online becasue it is going to the first one.
Thanks,
I got it to work. I had to alter some of the code. I got rid of the arrays and the loop. I did use the rest of your coding. I appreciate your help.
Glad you got it working! Please mark the most helpful post(s) asAnswer for the sake of future readers. Thank you.
0 comments:
Post a Comment