How to Ping servers faster

  • Thread starter Thread starter Wensi Peng
  • Start date Start date
W

Wensi Peng

Hello,

I often run a batch file/VBscript from a central server to check or gather
information on remote servers one by one.
It takes long time for a few hundred servers. Taking PING for example, it
takes over 30 minutes.
I want to check each server online every 5 minutes ( e.g, ping srvinfo, sc,
other command-lines and WMI, ADSI, VBscipt).
How can I speed up the process by using a single server list and get a
consolidated result?

Please share your experiences.

Thanks,
Wensi
 
Wensi Peng said:
Hello,

I often run a batch file/VBscript from a central server to check or gather
information on remote servers one by one.
It takes long time for a few hundred servers. Taking PING for example, it
takes over 30 minutes.
I want to check each server online every 5 minutes ( e.g, ping srvinfo, sc,
other command-lines and WMI, ADSI, VBscipt).
How can I speed up the process by using a single server list and get a
consolidated result?

I don't think there is any way around the fact that pinging is less than
instantaneous. Since I suspect that much of the elapsed time has more to do
with network latency than CPU cycles, you might be able to split this up
into separate batch files.

In the simplest case, you would have one batch file/vbscript instance for
each remote server, doing something like (the following untested
air-pseudo-code:

::: pingtest.bat
(set upflag=TTL)
(set flagfile=%1.up)
(set gofile=%1.go)
%gofile% echo/%1 is going
if exist %1.up del %1.up
for /l %%C in (,,) do (
if not exist %gofile% goto:eof
ping %1 | find "%upflag%"
if errorlevel 1 (
if exist %1.up del %1.up
) else (
%1.up echo/%1 is up
)
)

your main script would work like this:

rem - start all of the separate pinging threads
for each server in serverlist (
start /nowait pingtest.bat %server%
)

rem - monitor server availability
for /l %%C in (,,) do (
await the elapse of the current 5-minute interval
echo/these servers are UP:
for %%F in (*.up) do echo/%%~nF
)

There are a lot of details missing in the above, for sure, but hopefully you
will get the idea. For example, if you have a 5-minute delay in the main
loop above, the freqency of the sampling will be less than once per 5 minute
interval. Also, if you are more concerned about those servers that are NOT
up, you would simply reverse the logic to ensure that a servername.down file
existed when the ping indicates no response.

There are a few gotchas too, for sure, one being the large number of batch
file instances running. Perhaps vbscript would have less of an impact in
this regard than batch. If you used wscript.exe, for example, there would
not be so many windows open. You could have each of these ping instances
responsible for a larger number of servers, but then the accounting might
become a bit more complicated. Finally, perhaps the best approach would be
to recode that part in a platform that allows multiple concurrent threads in
an instance.

/Al
 
You are pretty much going to have to go to a more robust solution that allows
multiple simultaneous code paths executing. Look at perl or jumping to a
programming language like c/c++/Delphi or now VB.NET will thread though I seem
to be hearing lately there are issues there still.

joe
 
Well..you could use the shell...its one at a time but faster than wmi (i
think) and works on pre 2003 xp machines

Set objShell = CreateObject("WScript.Shell")
strPingResults = LCase(objExec.StdOut.ReadAll)
If InStr(strPingResults, "reply from") Then
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
 
Back
Top