From 1b1c6c40694a82625de33982802b18f8fe89b2c3 Mon Sep 17 00:00:00 2001 From: Christian Kujau Date: Sun, 24 Jan 2010 20:32:41 +0100 Subject: [PATCH] Initial version --- plugins/other/tor_traffic | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 plugins/other/tor_traffic diff --git a/plugins/other/tor_traffic b/plugins/other/tor_traffic new file mode 100755 index 00000000..120607f1 --- /dev/null +++ b/plugins/other/tor_traffic @@ -0,0 +1,28 @@ +#!/bin/sh +# +# (c)2010 lists@nerdbynature.de +# +# Get accounting information from a running Tor server. +# + + +COOKIE=/opt/tor/.tor/control_auth_cookie +PORT=9051 + + +if [ "$1" = config ]; then + echo "graph_title Tor Traffic" + echo "graph_args --base 1000" + echo "graph_vlabel bytes in / out" + echo "graph_category network" + echo "down.label Download" + echo "down.type GAUGE" + echo "up.label Upload" + echo "up.type GAUGE" + exit 0 +fi + +/bin/echo -e "AUTHENTICATE \"`cat $COOKIE`\"\nGETINFO accounting/bytes\nQUIT" | nc localhost $PORT | \ + awk -F= '/accounting\/bytes/ {print $2}' | \ + tr -d '\015' | \ + awk '{print "down.value "$1 "\nup.value "$2}'