diff options
author | Daniel Friesel <derf@finalrewind.org> | 2011-06-14 23:33:13 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2011-06-15 00:55:30 +0200 |
commit | 4c6994eab7ebc33de5407221ff00cdf86ed4a09b (patch) | |
tree | 28b3b58e09379fdecd0cb9fad50730263bee8620 /bin/ekgping | |
parent | 5fb6171898be9d803bc4c7c1f684e29f45fab626 (diff) |
Show full spike only for rtt < 0.3ms, half spike otherwise
Diffstat (limited to 'bin/ekgping')
-rwxr-xr-x | bin/ekgping | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/bin/ekgping b/bin/ekgping index 5e4b9f4..020b1f0 100755 --- a/bin/ekgping +++ b/bin/ekgping @@ -13,6 +13,7 @@ our $VERSION = '0.1'; my $host = shift; my $id = 0; +my $rtt = 0; my $last_id = 0; my $beep; my $was_beep = 1; @@ -35,9 +36,14 @@ sub parse_ping_output { chomp($line); if ( $line - =~ m{ ^ \d+ \s bytes \s from \s \S+ \s icmp_req = (?<id> \d+ ) }x ) + =~ m{ ^ \d+ \s bytes \s from \s \S+ \s + icmp_req = (?<id> \d+ ) \s + ttl = (?<ttl> \d+ ) \s + time = (?<time> [0-9.]+) \s ms }x + ) { $id = $+{id}; + $rtt = $+{time}; } return; @@ -71,7 +77,12 @@ while ( usleep(100_000) ) { if ( $id != $last_id ) { $beep = 1; - print q{^}; + if ($rtt < 300) { + print q{^}; + } + else { + print q{-}; + } $last_id = $id; $dead_count = 0; } |