Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP server connection test [closed]

Tags:

php

Is there a php script/snippets out there that allows you to check a URL/IP for connection speed. Say example the URL is www.example.com and when I run the php script it will display how long it took to connect (211ms) to the URL/IP, I found some scripts that just show me if it's online or offline but not the speed it took.

I'm very aware of the free and paid services. I want create my own custom/private one to monitor my many servers and having trouble finding a simple script to connect to given locations.

like image 355
chillers Avatar asked Sep 17 '26 10:09

chillers


1 Answers

Maybe something like:

<?php
// Create a curl handle
$ch = curl_init('http://www.yahoo.com/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Execute
curl_exec($ch);

// Check if any error occured
if(!curl_errno($ch)) {
    $info = curl_getinfo($ch);
    echo 'Took ' . $info['total_time'] . ' seconds to send a request to ' . $info['url'];
}
// Close handle
curl_close($ch);
?>
like image 118
Kyle Hudson Avatar answered Sep 18 '26 22:09

Kyle Hudson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!