diff --git a/plugins/network/transmission b/plugins/network/transmission index f82092b5..e2d252f1 100755 --- a/plugins/network/transmission +++ b/plugins/network/transmission @@ -76,23 +76,25 @@ find this plugin on github at http://github.com/VolatileMesh/munin-plugins __version__ = '1.1' -import os, sys +import os +import sys from string import Template -plugin_name=list(os.path.split(sys.argv[0]))[1] -host = os.getenv('host','localhost') -port = os.getenv('port',9091) +plugin_name = list(os.path.split(sys.argv[0]))[1] +host = os.getenv('host', 'localhost') +port = os.getenv('port', 9091) user = os.getenv('user') passwd = os.getenv('pass') +title_host = '' if host in ['localhost', '127.0.0.1', '::1'] else ' on ' + host def config(): conf = Template("""multigraph ${plugin_name}_throughput -graph_title Transmission throughput for ${host} +graph_title Transmission throughput${title_host} graph_vlabel bytes/${graph_period} in (-) / out (+) graph_args --base 1000 graph_category network -graph_info This graph shows the throughput for Transmission torrents +graph_info This graph shows the throughput for Transmission torrents on ${host} down.label throughput down.type COUNTER down.draw AREA @@ -105,21 +107,21 @@ up.draw AREA up.min 0 multigraph ${plugin_name}_activity -graph_title Transmission activity for ${host} +graph_title Transmission activity${title_host} graph_vlabel torrents graph_args --base 1000 graph_category network -graph_info This graph shows the number of Transmission torrents +graph_info This graph shows the number of Transmission torrents on ${host} active.label active active.draw AREA active.min 0 -active.colour 77FF6F +active.colour COLOUR0 paused.label paused paused.draw STACK paused.min 0 -paused.colour 8F8F8F +paused.colour COLOUR8 """) - print conf.safe_substitute(plugin_name=plugin_name, host=host) + print conf.safe_substitute(plugin_name=plugin_name, host=host, title_host=title_host) sys.exit(0) @@ -131,7 +133,6 @@ def autoconf(): print 'no python module \'transmissionrpc\' missing' - def fetch(): import transmissionrpc @@ -172,7 +173,6 @@ def print_values_throughput(stats): print "up.value U" - def dumpstats(): import transmissionrpc try: @@ -185,14 +185,14 @@ def dumpstats(): if __name__ == '__main__': - if len(sys.argv)>1 : - if sys.argv[1]=="dumpstats" : - dumpstats() - elif sys.argv[1]=="config" : + if len(sys.argv) > 1 : + if sys.argv[1] == "dumpstats" : + dumpstats() + elif sys.argv[1] == "config" : config() - elif sys.argv[1]=="autoconf" : + elif sys.argv[1] == "autoconf" : autoconf() - elif sys.argv[1]!="": + elif sys.argv[1] != "": raise ValueError, "unknown parameter '%s'" % sys.argv[1] fetch()