Support the ongoing development of Laravel.io →
posted 4 years ago
Last updated 1 year ago.
0

updated PHP code that works on both Linux and MacOSX @ http://pastebin.ca/3058702

for those on Mac OSX's ping, sample output:

PING google.com (74.125.200.101): 56 data bytes 64 bytes from 74.125.200.101: icmp_seq=0 ttl=47 time=5.068 ms 64 bytes from 74.125.200.101: icmp_seq=1 ttl=47 time=4.992 ms 64 bytes from 74.125.200.101: icmp_seq=2 ttl=47 time=6.558 ms 64 bytes from 74.125.200.101: icmp_seq=3 ttl=47 time=104.087 ms

--- google.com ping statistics --- 4 packets transmitted, 4 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 4.992/30.176/104.087/42.677 ms fixes to code:

//grab each ping line $pingLineRegex = "/([0-9]+) bytes from ([^\s]+)(?: ((.+)))?: icmp_seq=([0-9]+) ttl=([0-9]+) time=([0-9.]+) ms/";

//grab aggregated results @ btm $pingResultRegex = $re = "/--- (.+) ping statistics ---\n([0-9]+) packets transmitted, ([0-9]+)(?: packets)? received, ([0-9\.]+)% packet loss(?:, time ([0-9]+)ms)?\n(?:round\-trip|rtt)? min\/avg\/max\/(?:stddev|mdev)? = ([0-9\.]+)\/([0-9\.]+)\/([0-9\.]+)\/([0-9\.]+) ms/"; ... "ip" => $pingLineMatches[3][$i] ?: $pingLineMatches[2][$i], ... "time" => empty($pingResultMatches[5][0]) ? array(0) : $pingResultMatches[5], dissertation writing services

Last updated 4 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.