2012-07-08 12:45:58 by jdixon
Here's an embarrassingly simple script I threw together this morning to track network latency to a handful of remote websites/networks from my home internet. Yes, I understand that these numbers are highly influenced by my proximity to various CDN networks and bear no resemblance to how actual web browsing would perform concurrently. That isn't the point. This is merely to demonstrate a cheap and easy way to get more metrics into Graphite; and at the same time, providing me with some useful reference for when my home internet provider will inevitably have hiccups.
#!/bin/sh for i in foobar yahoo.com google.com heroku.com; do HOST=$i; NAME=`echo -n $i | cut -d'.' -f1`; echo "custom.`hostname | sed 's/\./\-/g'`.network.ping.latency.$NAME \ `ping -q -c 1 -n $HOST | tail -1 | cut -d'=' -f2 | cut -d'/' -f2` `date +%s`" | \ nc graphite.mydomain.com 2003; done
I run this from cron each minute on one of my home servers. Here is the resulting graph for the last 30 minutes:
And the graph target definitions:
aliasByMetric(color(custom.home-server.network.ping.latency.google,"red")) aliasByMetric(color(custom.home-server.network.ping.latency.heroku,"purple")) aliasByMetric(color(custom.home-server.network.ping.latency.foobar,"orange")) aliasByMetric(color(custom.home-server.network.ping.latency.yahoo,"blue"))