El Cheapo Network Graph

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"))

Comments

at 2015-11-16 17:04:28, Sven wrote in to say...

Hello; and thanks very much for the script!

Very nice, not so easy for me to put things like this together. So very helpful.

On a side note; I was hoping you might know off hand how I might feed an ip address into graphite as metric value?

ie. 192.168.2.55

The ip address on my server changes infrequently and I was hoping I could run a cronjob to update the address in graphite via bash.

-S

Add a comment:

  name

  email

  url

max length 4000 chars