par
MaKKrO » 16 juil. 2006, 09:48
Salut a tous,
Voila, j'ai un petit script php qui teste la connexion grace a un ping.
Mon code :
require_once 'Ping.php';
$ping = Net_Ping::factory();
if(PEAR::isError($ping)) {
die($ping->getMessage());
}
$ping->setArgs(array('count' => 4));
$result = $ping->ping('google.com');
echo "<pre>";
//dump the raw data
print_r($result);
echo "</pre>";
Le resultat est la suivant :
Code : Tout sélectionner
Net_Ping_Result Object
(
[_icmp_sequence] => Array
(
[1] => 227
[2] => 227
[3] => 226
[4] => 227
)
[_target_ip] => 64.233.187.99
[_bytes_per_request] => 64
[_bytes_total] => 320
[_ttl] => 236
[_raw_data] => Array
(
[0] => PING google.com (64.233.187.99) 56(84) bytes of data.
[1] => 64 bytes from 64.233.187.99: icmp_seq=1 ttl=236 time=227 ms
[2] => 64 bytes from 64.233.187.99: icmp_seq=2 ttl=236 time=227 ms
[3] => 64 bytes from 64.233.187.99: icmp_seq=3 ttl=236 time=226 ms
[4] => 64 bytes from 64.233.187.99: icmp_seq=4 ttl=236 time=227 ms
[5] =>
[6] => --- google.com ping statistics ---
[7] => 4 packets transmitted, 4 received, 0% packet loss, time 3013ms
[8] => rtt min/avg/max/mdev = 226.758/227.354/227.865/0.713 ms
)
[_sysname] => linux
[_round_trip] => Array
(
[min] => 227.354
[avg] => 227.865
[max] => 0.713
)
[_transmitted] => 4
[_received] => 4
[_loss] => 0
)
J'essai mais en vain de recuperer les valeurs 'transmitted' et 'received'...
J'ai essayer :
ou encore
ca me sort toujours un
Je cherche sur le net, mais je ne sais pas trop la....
Si quelqu'un peut m'aider !
Merci
Salut a tous,
Voila, j'ai un petit script php qui teste la connexion grace a un ping.
Mon code :
[php]
require_once 'Ping.php';
$ping = Net_Ping::factory();
if(PEAR::isError($ping)) {
die($ping->getMessage());
}
$ping->setArgs(array('count' => 4));
$result = $ping->ping('google.com');
echo "<pre>";
//dump the raw data
print_r($result);
echo "</pre>";
[/php]
Le resultat est la suivant :
[code]
Net_Ping_Result Object
(
[_icmp_sequence] => Array
(
[1] => 227
[2] => 227
[3] => 226
[4] => 227
)
[_target_ip] => 64.233.187.99
[_bytes_per_request] => 64
[_bytes_total] => 320
[_ttl] => 236
[_raw_data] => Array
(
[0] => PING google.com (64.233.187.99) 56(84) bytes of data.
[1] => 64 bytes from 64.233.187.99: icmp_seq=1 ttl=236 time=227 ms
[2] => 64 bytes from 64.233.187.99: icmp_seq=2 ttl=236 time=227 ms
[3] => 64 bytes from 64.233.187.99: icmp_seq=3 ttl=236 time=226 ms
[4] => 64 bytes from 64.233.187.99: icmp_seq=4 ttl=236 time=227 ms
[5] =>
[6] => --- google.com ping statistics ---
[7] => 4 packets transmitted, 4 received, 0% packet loss, time 3013ms
[8] => rtt min/avg/max/mdev = 226.758/227.354/227.865/0.713 ms
)
[_sysname] => linux
[_round_trip] => Array
(
[min] => 227.354
[avg] => 227.865
[max] => 0.713
)
[_transmitted] => 4
[_received] => 4
[_loss] => 0
)
[/code]
J'essai mais en vain de recuperer les valeurs 'transmitted' et 'received'...
J'ai essayer :
[code]
$result-> _transmitted;
echo $result;
[/code]
ou encore
[code]
$result-> _round_trip['min'];
[/code]
ca me sort toujours un [code]Object id #2
[/code]
Je cherche sur le net, mais je ne sais pas trop la....
Si quelqu'un peut m'aider !
Merci