Pinging sites

Discussion in 'PHP' started by mark2048, May 29, 2011.

  1. #1
    What is the most efficient way of pinging a large number of sites? I'm trying to gather data.

    Thanks
     
    mark2048, May 29, 2011 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,899
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #2
    sarahk, May 29, 2011 IP
  3. x319

    x319 Well-Known Member

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    103
    #3
    I had made a script while back for a client that pinged about 200 websites every 10 minutes. This was the fastest solution that met up to ping those sites efficiently:
    function ping($host) {
    	$s = shell_exec("ping -c 1 -w 1 {$host}");
    	$r = "/mdev = (.*)\/(.*)\/(.*)\/(.*) ms/";
    	preg_match($r, $s, $m);
    	return $m ? $m[1] : false;
    }
    PHP:
    It also returns the ping time ;)

    ** It most likely won't work on shared hosts though as most hosts disable the shell_exec call. In that case you can use cURL to ping the site or open a socket connection and time it.
     
    x319, May 29, 2011 IP
  4. piluan

    piluan Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    thank you !
     
    piluan, May 30, 2011 IP
  5. mark2048

    mark2048 Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #5
    thanks, I'll take a look at those scripts
     
    mark2048, May 30, 2011 IP
  6. chanif.alfath

    chanif.alfath Active Member

    Messages:
    148
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    88
    #6
    good script..

    thanks,
    and btw, you can use curl too,
    like this :

     
    chanif.alfath, May 31, 2011 IP
  7. DomainerHelper

    DomainerHelper Well-Known Member

    Messages:
    445
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    100
    #7
    All pinging will do is show you hop times and the like, not really gather data other than that. If you mean scraper, let me know the user agent you use so I can blacklist you for stealing content.
     
    DomainerHelper, May 31, 2011 IP