Sign in to follow this  
Followers 0
danz

Ping large amount of devices

4 posts in this topic

First of all my hats off to the developers, you have something great here! I have been reading though docs and playing around with code and I have decided to build a network status tool for myself at work. I am using the ping command and for now dropping the results into a txt file but plan on adding mysql support and changing a status indicator in a gui. One of the problems I ran into that I have not been able to work around is the 21 limit of _ArrayCreate. If I can get over this hurdle I will be needing to ping upwards pf 200-300 devices. If you can lend any assistance on an alternative method of piping in the ip's I need to ping over 21 I would appreciate it.

CODE
$ip = _ArrayCreate("127.0.0.1","127.0.0.1")

$pinglog = @ScriptDir & "\pinglog.txt"

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case Else

For $i = 0 to UBound ($ip)-1 Step 1

$var = Ping($ip[$i],250)

If $var Then

FileWriteLine($pinglog,_NowCalc() & " - " & $ip[$i] & " - Online")

Else

FileWriteLine($pinglog,_NowCalc() & " - " & $ip[$i] & " - No Response")

EndIf

Next

;MsgBox(0,"", "Sleep Start")

Sleep (9000)

;MsgBox(0,"", "Sleep End")

EndSwitch

WEnd

Share this post


Link to post
Share on other sites



Doh!

That does the trick, I had to make one other change because the first item contained the length of the string.

Changed the 0 to a 1

CODE
For $i = 0 to UBound ($ip)-1 Step 1

$var = Ping($ip[$i],250)

If $var Then

FileWriteLine($pinglog,_NowCalc() & " - " & $ip[$i] & " - Online")

Else

FileWriteLine($pinglog,_NowCalc() & " - " & $ip[$i] & " - No Response")

EndIf

Next

I also noticed that this process is also more CPU intensive. Is this just cause I am doing more values or are strings not as efficient as arrays?

Share this post


Link to post
Share on other sites

After the line with the StringSplit command everything should be equally fast. It is faster to Dim the array in a normal way, but you'll have to type a lot more.

How to Dim an Array?

Dim $IP[2] = ["127.0.0.1","127.0.0.1"]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0