#!/usr/bin/env perl use strict; use warnings; use autodie; use Data::Dumper; use Time::HiRes qw(time); use Statistics::Descriptive; =head1 NAME ping-monitor.pl - Live ping statistics =head1 SYNOPSIS ping-monitor.pl =head1 DESCRIPTION ping-monitor.pl provides live mean, median, standard deviation and packet loss statistics similar to ping(8). The statistics are calculated over the last 10 seconds by default. =cut if (0+@ARGV < 1) { print "usage: $0 \n"; exit 0; } my $host = $ARGV[0]; # a value < 0.2 requires root privileges my $frequency = 0.2; # 10 second average my $window_size = 10/$frequency; open my $ping, "-|", "ping -nDOi $frequency -W 1 $host"; my @history; my $last_reply = 0; # ensure we are on a clean line for cleaning later printf "\n"; while (<$ping>) { next if m/^PING /; if (m/^\[(?[0-9.]+)\] \d+ bytes from [^:]+: icmp_seq=\d+ ttl=\d+ time=(?