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.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)
|
||||
|
||||
|
||||
|
@ -130,7 +130,7 @@ def autoconf():
|
|||
import transmissionrpc
|
||||
print('yes')
|
||||
except ImportError:
|
||||
print 'no python module \'transmissionrpc\' missing'
|
||||
print('no python module \'transmissionrpc\' missing')
|
||||
|
||||
|
||||
def fetch():
|
||||
|
@ -138,8 +138,8 @@ def fetch():
|
|||
|
||||
try:
|
||||
client = transmissionrpc.Client(host, port=port, user=user, password=passwd)
|
||||
except transmissionrpc.TransmissionError, err:
|
||||
print err
|
||||
except transmissionrpc.TransmissionError as err:
|
||||
print(err)
|
||||
sys.exit(1)
|
||||
|
||||
stats = client.session_stats(10)
|
||||
|
@ -148,40 +148,40 @@ def fetch():
|
|||
|
||||
|
||||
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:
|
||||
print "active.value %s" % stats.activeTorrentCount
|
||||
print("active.value %s" % stats.activeTorrentCount)
|
||||
except:
|
||||
print "active.value U"
|
||||
print("active.value U")
|
||||
|
||||
try:
|
||||
print "paused.value %s" % stats.pausedTorrentCount
|
||||
print("paused.value %s" % stats.pausedTorrentCount)
|
||||
except:
|
||||
print "paused.value U"
|
||||
print("paused.value U")
|
||||
|
||||
|
||||
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:
|
||||
print "down.value %s" % stats.cumulative_stats['downloadedBytes']
|
||||
print("down.value %s" % stats.cumulative_stats['downloadedBytes'])
|
||||
except:
|
||||
print "down.value U"
|
||||
print("down.value U")
|
||||
|
||||
try:
|
||||
print "up.value %s" % stats.cumulative_stats['uploadedBytes']
|
||||
print("up.value %s" % stats.cumulative_stats['uploadedBytes'])
|
||||
except:
|
||||
print "up.value U"
|
||||
print("up.value U")
|
||||
|
||||
|
||||
def dumpstats():
|
||||
import transmissionrpc
|
||||
try:
|
||||
client = transmissionrpc.Client(host, port=port, user=user, password=passwd)
|
||||
except transmissionrpc.transmission.TransmissionError, err:
|
||||
print err
|
||||
except transmissionrpc.transmission.TransmissionError as err:
|
||||
print(err)
|
||||
sys.exit(1)
|
||||
stats = client.session_stats(10)
|
||||
print stats
|
||||
print(stats)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -193,7 +193,7 @@ if __name__ == '__main__':
|
|||
elif sys.argv[1] == "autoconf" :
|
||||
autoconf()
|
||||
elif sys.argv[1] != "":
|
||||
raise ValueError, "unknown parameter '%s'" % sys.argv[1]
|
||||
raise ValueError("unknown parameter '%s'" % sys.argv[1])
|
||||
|
||||
fetch()
|
||||
sys.exit(0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue