mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 02:51:03 +00:00
[plugins/transmission] Python3 compat
Signed-off-by: Olivier Mehani <shtrom@ssji.net>
This commit is contained in:
parent
3b478bab2f
commit
d25a9e9428
1 changed files with 18 additions and 18 deletions
|
@ -121,7 +121,7 @@ paused.draw STACK
|
||||||
paused.min 0
|
paused.min 0
|
||||||
paused.colour COLOUR8
|
paused.colour COLOUR8
|
||||||
""")
|
""")
|
||||||
print conf.safe_substitute(plugin_name=plugin_name, host=host, title_host=title_host)
|
print(conf.safe_substitute(plugin_name=plugin_name, host=host, title_host=title_host))
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ def autoconf():
|
||||||
import transmissionrpc
|
import transmissionrpc
|
||||||
print('yes')
|
print('yes')
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print 'no python module \'transmissionrpc\' missing'
|
print('no python module \'transmissionrpc\' missing')
|
||||||
|
|
||||||
|
|
||||||
def fetch():
|
def fetch():
|
||||||
|
@ -138,8 +138,8 @@ def fetch():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
client = transmissionrpc.Client(host, port=port, user=user, password=passwd)
|
client = transmissionrpc.Client(host, port=port, user=user, password=passwd)
|
||||||
except transmissionrpc.TransmissionError, err:
|
except transmissionrpc.TransmissionError as err:
|
||||||
print err
|
print(err)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
stats = client.session_stats(10)
|
stats = client.session_stats(10)
|
||||||
|
@ -148,40 +148,40 @@ def fetch():
|
||||||
|
|
||||||
|
|
||||||
def print_values_activity(stats):
|
def print_values_activity(stats):
|
||||||
print "multigraph {plugin_name}_activity".format(plugin_name=plugin_name)
|
print("multigraph {plugin_name}_activity".format(plugin_name=plugin_name))
|
||||||
try:
|
try:
|
||||||
print "active.value %s" % stats.activeTorrentCount
|
print("active.value %s" % stats.activeTorrentCount)
|
||||||
except:
|
except:
|
||||||
print "active.value U"
|
print("active.value U")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
print "paused.value %s" % stats.pausedTorrentCount
|
print("paused.value %s" % stats.pausedTorrentCount)
|
||||||
except:
|
except:
|
||||||
print "paused.value U"
|
print("paused.value U")
|
||||||
|
|
||||||
|
|
||||||
def print_values_throughput(stats):
|
def print_values_throughput(stats):
|
||||||
print "multigraph {plugin_name}_throughput".format(plugin_name=plugin_name)
|
print("multigraph {plugin_name}_throughput".format(plugin_name=plugin_name))
|
||||||
try:
|
try:
|
||||||
print "down.value %s" % stats.cumulative_stats['downloadedBytes']
|
print("down.value %s" % stats.cumulative_stats['downloadedBytes'])
|
||||||
except:
|
except:
|
||||||
print "down.value U"
|
print("down.value U")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
print "up.value %s" % stats.cumulative_stats['uploadedBytes']
|
print("up.value %s" % stats.cumulative_stats['uploadedBytes'])
|
||||||
except:
|
except:
|
||||||
print "up.value U"
|
print("up.value U")
|
||||||
|
|
||||||
|
|
||||||
def dumpstats():
|
def dumpstats():
|
||||||
import transmissionrpc
|
import transmissionrpc
|
||||||
try:
|
try:
|
||||||
client = transmissionrpc.Client(host, port=port, user=user, password=passwd)
|
client = transmissionrpc.Client(host, port=port, user=user, password=passwd)
|
||||||
except transmissionrpc.transmission.TransmissionError, err:
|
except transmissionrpc.transmission.TransmissionError as err:
|
||||||
print err
|
print(err)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
stats = client.session_stats(10)
|
stats = client.session_stats(10)
|
||||||
print stats
|
print(stats)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -193,7 +193,7 @@ if __name__ == '__main__':
|
||||||
elif sys.argv[1] == "autoconf" :
|
elif sys.argv[1] == "autoconf" :
|
||||||
autoconf()
|
autoconf()
|
||||||
elif sys.argv[1] != "":
|
elif sys.argv[1] != "":
|
||||||
raise ValueError, "unknown parameter '%s'" % sys.argv[1]
|
raise ValueError("unknown parameter '%s'" % sys.argv[1])
|
||||||
|
|
||||||
fetch()
|
fetch()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue