From e254623ba1f1e9ad05c06ce1fd1e1c692b079107 Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Wed, 27 May 2020 17:55:50 +1000 Subject: [PATCH 1/3] [plugins/transmission] Fixups for consistency Use standard colours for the transmission_activity plot (but keep a darker one for paused torrents). Also, remove the ${host} from the graph_title, and add it in the graph_info, for better groupability. Signed-off-by: Olivier Mehani --- plugins/network/transmission | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/network/transmission b/plugins/network/transmission index f82092b5..e87613ef 100755 --- a/plugins/network/transmission +++ b/plugins/network/transmission @@ -88,11 +88,11 @@ passwd = os.getenv('pass') def config(): conf = Template("""multigraph ${plugin_name}_throughput -graph_title Transmission throughput for ${host} +graph_title Transmission throughput 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,19 +105,19 @@ up.draw AREA up.min 0 multigraph ${plugin_name}_activity -graph_title Transmission activity for ${host} +graph_title Transmission activity 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) sys.exit(0) From 897de1bbbac8bee0bb098c9b0f73185ad09e2d93 Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Mon, 31 Aug 2020 12:55:40 +1000 Subject: [PATCH 2/3] squash! [plugins/transmission] Fixups for consistency Only show host in title when not localhost --- plugins/network/transmission | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/network/transmission b/plugins/network/transmission index e87613ef..d07a8e18 100755 --- a/plugins/network/transmission +++ b/plugins/network/transmission @@ -84,11 +84,12 @@ 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 +graph_title Transmission throughput${title_host} graph_vlabel bytes/${graph_period} in (-) / out (+) graph_args --base 1000 graph_category network @@ -105,7 +106,7 @@ up.draw AREA up.min 0 multigraph ${plugin_name}_activity -graph_title Transmission activity +graph_title Transmission activity${title_host} graph_vlabel torrents graph_args --base 1000 graph_category network @@ -119,7 +120,7 @@ paused.draw STACK paused.min 0 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) From 92483a045ba48d3bd669666b77c9ec23f11ae557 Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Mon, 31 Aug 2020 12:56:14 +1000 Subject: [PATCH 3/3] [plugins/transmission] Lint Signed-off-by: Olivier Mehani --- plugins/network/transmission | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/plugins/network/transmission b/plugins/network/transmission index d07a8e18..e2d252f1 100755 --- a/plugins/network/transmission +++ b/plugins/network/transmission @@ -76,12 +76,13 @@ 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 @@ -132,7 +133,6 @@ def autoconf(): print 'no python module \'transmissionrpc\' missing' - def fetch(): import transmissionrpc @@ -173,7 +173,6 @@ def print_values_throughput(stats): print "up.value U" - def dumpstats(): import transmissionrpc try: @@ -186,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()