1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

Merge pull request #1086 from shtrom/transmission-consistency-fixups

[plugins/transmission] Fixups for consistency
This commit is contained in:
Lars Kruse 2020-09-06 21:56:39 +02:00 committed by GitHub
commit 81bdedaf42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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()