gnu plot ping time with python

#!/usr/bin/python
# Author: Tancredi-Paul Grozav <paul@grozav.info>
# All rights reserved
import sys

maxPointsPerScreen = 20
points = []
for line in iter(sys.stdin.readline, ""):
    if "bytes from" in line:
        words = line.split()
        command = ""
        if len(points) > maxPointsPerScreen:
            command += "set xrange ["+str(len(points)-maxPointsPerScreen)+":"+str(len(points))+"]\n"
        command += "plot '-' w lines;\n"
        points.append( [ len(points), words[7][5:] ] )
        for point in points:
            command += str(point[0])+" "+str(point[1])+"\n"
        command += "e\n"
        sys.stdout.write(command)
        sys.stdout.flush()

You must install the package gnuplot with your package manager, and then you can run the program like this:

ping debian.org | ./parse.py | gnuplot