I recently had the need to generate a graph of ping times between my PC and a British Telecom server. After a quick web search the only options I found were commercial programs or free software that was incredibly bloated, complex to configure and with lots of dependencies. There must be a simpler way, and there is. Perl.

Here is my script:

# Converts ping output into a CSV file for graphing
# andy at british ideas dot com - March 29th 2011
# Public Domain
# Run using:
# ping -D | ./pingtocsv.pl > output.csv
# or:
# cat pingdump.txt | ./pingtocsv.pl > output.csv
print "Measurement Time,Ping Time\n";
while (<STDIN>) {
  if ($_ =~ m/^\[([0-9\.]+)\].*time\=([0-9\.]+).*/i) {
    print "$1,$2\n";

Run this using something like:

ping -D | ./perltocsv.pl > pingtimes.csv

This will generate a CSV file. Hit Ctrl-C to terminate. Now use LibreOffice to open the CSV file and generate a graph. Here is mine (click to enlarge):