Skip to content

Instantly share code, notes, and snippets.

@ntang-livestream
Forked from mrtazz/graphline.sh
Created July 21, 2012 02:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ntang-livestream/3154329 to your computer and use it in GitHub Desktop.
Save ntang-livestream/3154329 to your computer and use it in GitHub Desktop.
shell function to quickly check a graphite graph
#
# shell function to print graphite graphs as sparklines in the terminal
# needs https://github.com/holman/spark
# from: https://twitter.com/mrtazz/status/226297265512402946
#
function graphline() {
GRAPHITEHOST="graphite.example.com"
if [ ! -n "$1" ]; then echo "Usage: $FUNCNAME METRIC [minutes]"; return 1; fi
if [ ! -n "$2" ]; then MINUTES=10 ; else MINUTES=$2; fi
curl -s "${GRAPHITEHOST}/render?from=-${MINUTES}minutes&target=${1}&format=raw" | sed s/,None//g | cut -d"|" -f 2 | spark ;
}
@ntang-livestream
Copy link
Author

Cleaned up the original a bit; $0 didn't work with a bash function (just returned "bash"), added the pipe to sed to remove any blank data...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment