mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-24 18:07:20 +00:00
Improve code style
This commit is contained in:
parent
5fd233c510
commit
1c0739641f
1 changed files with 24 additions and 24 deletions
|
@ -1,4 +1,4 @@
|
|||
#! /usr/bin/env python
|
||||
#! /usr/bin/env python2
|
||||
#
|
||||
# Munin Wildcard Plugin for Deluge torrent client
|
||||
#
|
||||
|
@ -51,6 +51,8 @@ import os
|
|||
import string
|
||||
import sys
|
||||
from twisted.internet import reactor, defer
|
||||
|
||||
|
||||
setupLogger()
|
||||
|
||||
plugin_version = "1.0.0"
|
||||
|
@ -147,14 +149,14 @@ class StatClient:
|
|||
|
||||
def on_num_connections(self, num_connections):
|
||||
log.debug("Got num_connections from the daemon : {0}".format(
|
||||
str(num_connections)))
|
||||
print "{0}.value {1}".format(
|
||||
names_for_munin["numConnections"], num_connections)
|
||||
num_connections))
|
||||
print("{0}.value {1}".format(
|
||||
names_for_munin["numConnections"], num_connections))
|
||||
self.end_session("Done")
|
||||
|
||||
def on_bandwidth(self, values):
|
||||
log.debug(
|
||||
"Got bandwidth info from the daemon : {0}".format(str(values)))
|
||||
"Got bandwidth info from the daemon : {0}".format(values))
|
||||
|
||||
download_rate = values['download_rate']
|
||||
payload_download_rate = values['payload_download_rate']
|
||||
|
@ -163,15 +165,14 @@ class StatClient:
|
|||
payload_upload_rate = values['payload_upload_rate']
|
||||
overhead_upload_rate = upload_rate - payload_upload_rate
|
||||
|
||||
print "{0}.value {1}".format(
|
||||
names_for_munin["payloadDownloadRate"], payload_download_rate)
|
||||
print "{0}.value {1}".format(
|
||||
names_for_munin["overheadDownloadRate"], overhead_download_rate)
|
||||
print "{0}.value {1}".format(
|
||||
names_for_munin["payloadUploadRate"], payload_upload_rate)
|
||||
print "{0}.value {1}".format(
|
||||
names_for_munin["overheadUploadRate"], overhead_upload_rate)
|
||||
|
||||
print("{0}.value {1}".format(
|
||||
names_for_munin["payloadDownloadRate"], payload_download_rate))
|
||||
print("{0}.value {1}".format(
|
||||
names_for_munin["overheadDownloadRate"], overhead_download_rate))
|
||||
print("{0}.value {1}".format(
|
||||
names_for_munin["payloadUploadRate"], payload_upload_rate))
|
||||
print("{0}.value {1}".format(
|
||||
names_for_munin["overheadUploadRate"], overhead_upload_rate))
|
||||
self.end_session("Done")
|
||||
|
||||
def on_session_state(self, torrent_ids):
|
||||
|
@ -210,24 +211,24 @@ class StatClient:
|
|||
self.states[state] = self.states[state] + 1
|
||||
|
||||
def on_all_torrent_info_fetched(self, res):
|
||||
log.debug("on_all_torrent_info_fetched : {0}".format(str(self.states)))
|
||||
log.debug("on_all_torrent_info_fetched : {0}".format(self.states))
|
||||
|
||||
for state in self.states:
|
||||
print "{0}.value {1}".format(
|
||||
names_for_munin["state." + state], self.states[state])
|
||||
print("{0}.value {1}".format(
|
||||
names_for_munin["state." + state], self.states[state]))
|
||||
|
||||
self.end_session("Done")
|
||||
|
||||
|
||||
def get_mode():
|
||||
script_name = list(os.path.split(sys.argv[0]))[1]
|
||||
script_name = os.path.basename(sys.argv[0])
|
||||
mode = script_name[string.rindex(script_name, '_') + 1:]
|
||||
|
||||
log.debug("Mode : {0}".format(str(mode)))
|
||||
log.debug("Mode : {0}".format(mode))
|
||||
|
||||
if not mode in modes:
|
||||
if mode not in modes:
|
||||
log.error("Unknown mode '{0}'".format(mode))
|
||||
log.info("Available modes are : {0}".format(str(modes)))
|
||||
log.info("Available modes are : {0}".format(modes))
|
||||
sys.exit(1)
|
||||
|
||||
return mode
|
||||
|
@ -280,9 +281,8 @@ def print_config(mode):
|
|||
elif mode == "states":
|
||||
print("graph_title Torrents states")
|
||||
|
||||
graph_order = ""
|
||||
for state_name in torrent_states:
|
||||
graph_order += names_for_munin["state." + state_name] + " "
|
||||
graph_order = " ".join(
|
||||
[names_for_munin["state.{}".format(name)] for name in torrent_states])
|
||||
|
||||
print("graph_order " + graph_order)
|
||||
print("graph_args --base 1000 -r --lower-limit 0")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue