1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-22 02:51:03 +00:00

Fix python style issues reported by flake8

Additionally some python2-only "print" statements are now compatible
with python3.
This commit is contained in:
Lars Kruse 2019-12-18 00:25:39 +01:00
parent 73f885e382
commit 7063330e03
17 changed files with 102 additions and 103 deletions

View file

@ -126,8 +126,8 @@ def print_config():
print("graph_category backup") print("graph_category backup")
print("graph_order", " ".join(fd[1] for fd in clients)) print("graph_order", " ".join(fd[1] for fd in clients))
print() print()
if ((os.getenv("report_hostname") is not None) and if ((os.getenv("report_hostname") is not None)
(os.getenv("report_hostname").upper() in ["YES", "TRUE", "1", "Y"])): and (os.getenv("report_hostname").upper() in ["YES", "TRUE", "1", "Y"])):
print("host_name", hostname) print("host_name", hostname)
for client in clients: for client in clients:
print("%s.label %s" % (client[1], client[0])) print("%s.label %s" % (client[1], client[0]))

View file

@ -11,7 +11,7 @@ API_KEY = sys.argv[0][(sys.argv[0].rfind('_')+1):]
STATS = URL + API_KEY STATS = URL + API_KEY
print STATS print(STATS)
command = '' command = ''
if len(sys.argv) > 1: if len(sys.argv) > 1:
@ -25,16 +25,16 @@ workers = mining_stats['workers']
if command == 'config': if command == 'config':
print "graph_title BTCGuild Hashrate" print("graph_title BTCGuild Hashrate")
print "graph_args --upper-limit 3000 -l 0" print("graph_args --upper-limit 3000 -l 0")
print "graph_vlabel MHash/s" print("graph_vlabel MHash/s")
print "graph_category htc" print("graph_category htc")
for worker in workers: for worker in workers:
label = workers[worker]['worker_name'] label = workers[worker]['worker_name']
print label + ".label " + label print(label + ".label " + label)
sys.exit(0) sys.exit(0)
for worker in workers: for worker in workers:
hash_rate = workers[worker]['hash_rate'] hash_rate = workers[worker]['hash_rate']
label = workers[worker]['worker_name'] label = workers[worker]['worker_name']
print label + ".value %d" % int(hash_rate) print(label + ".value %d" % int(hash_rate))

View file

@ -91,21 +91,21 @@ graph_types = {
if len(sys.argv) == 2 and sys.argv[1] == "autoconf": if len(sys.argv) == 2 and sys.argv[1] == "autoconf":
print "yes" print("yes")
elif len(sys.argv) == 2 and sys.argv[1] == "config": elif len(sys.argv) == 2 and sys.argv[1] == "config":
if graph_type not in graph_types.keys(): if graph_type not in graph_types.keys():
raise Exception("Unknown graph type '%s'" % graph_type) raise Exception("Unknown graph type '%s'" % graph_type)
params = graph_types[graph_type] params = graph_types[graph_type]
for item in params: for item in params:
print "graph_title %s" % item["title"] print("graph_title %s" % item["title"])
print "graph_category webserver" print("graph_category webserver")
for field in item["fields"]: for field in item["fields"]:
print "%s.label %s" % (field, field) print("%s.label %s" % (field, field))
print "%s.type %s" % (field, item["type"]) print("%s.type %s" % (field, item["type"]))
print "graph_args %s" % item["args"] print("graph_args %s" % item["args"])
elif len(sys.argv) == 2 and sys.argv[1] == "suggest": elif len(sys.argv) == 2 and sys.argv[1] == "suggest":
for item in graph_types.keys(): for item in graph_types.keys():
print item print(item)
else: else:
status_url = os.environ.get('status_url', 'http://127.0.0.1/server-status') status_url = os.environ.get('status_url', 'http://127.0.0.1/server-status')
@ -129,11 +129,11 @@ else:
pass pass
if graph_type == "accesses": if graph_type == "accesses":
print "accesses.value %s" % data["Total Accesses"] print("accesses.value %s" % data["Total Accesses"])
elif graph_type == "kbytes": elif graph_type == "kbytes":
print "kbytes.value %s" % data["Total kBytes"] print("kbytes.value %s" % data["Total kBytes"])
elif graph_type == "uptime": elif graph_type == "uptime":
print "uptime.value %s" % str(float(data["Uptime"])/86400) print("uptime.value %s" % str(float(data["Uptime"]) / 86400))
elif graph_type == "status": elif graph_type == "status":
print "busy.value %s" % data["BusyServers"] print("busy.value %s" % data["BusyServers"])
print "idle.value %s" % data["IdleServers"] print("idle.value %s" % data["IdleServers"])

View file

@ -197,7 +197,7 @@ print(
"""multigraph technicolor_tc8715d_snr """multigraph technicolor_tc8715d_snr
graph_title Technicolor TC8715D Cable Modem SNR graph_title Technicolor TC8715D Cable Modem SNR
graph_vlabel Signal-to-Noise Ratio (dB) graph_vlabel Signal-to-Noise Ratio (dB)
graph_info This graph shows the downstream signal-to-noise ratio reported by a Technicolor TC8715D cable modem. graph_info Downstream signal-to-noise ratio reported by a Technicolor TC8715D cable modem.
graph_category network""" graph_category network"""
) )
@ -212,7 +212,7 @@ print(
"""multigraph technicolor_tc8715d_codewords """multigraph technicolor_tc8715d_codewords
graph_title Technicolor TC8715D Cable Modem Codewords graph_title Technicolor TC8715D Cable Modem Codewords
graph_vlabel Codewords/${graph_period} graph_vlabel Codewords/${graph_period}
graph_info This graph shows the downstream codeword rates reported by a Technicolor TC8715D cable modem. graph_info Downstream codeword rates reported by a Technicolor TC8715D cable modem.
graph_category network""" graph_category network"""
) )

View file

@ -77,7 +77,7 @@ def parse_params():
data = params['core'].rsplit('_', 1) data = params['core'].rsplit('_', 1)
handler = data.pop() handler = data.pop()
params['params'] = { params['params'] = {
'handler': os.environ.get('qpshandler_%s' % handler, 'standard') 'handler': os.environ.get('qpshandler_%s' % handler, 'standard'),
} }
if not data: if not data:
params['core'] = '' params['core'] = ''

View file

@ -119,21 +119,21 @@ class SynologySNMPClient(object):
return int(varBindTable[0][1]) return int(varBindTable[0][1])
def print_config(self): def print_config(self):
print """multigraph synology_hdd_temperatures print("""multigraph synology_hdd_temperatures
host_name {hostname} host_name {hostname}
graph_title HDD temperatures on {hostname} graph_title HDD temperatures on {hostname}
graph_vlabel Temperature in °C graph_vlabel Temperature in °C
graph_args --base 1000 graph_args --base 1000
graph_category sensors graph_category sensors
graph_info HDD temperatures on {hostname}""".format(hostname=self.hostname) graph_info HDD temperatures on {hostname}""".format(hostname=self.hostname))
for id, name, model, temp in self._get_disks(): for id, name, model, temp in self._get_disks():
print """disk{disk_id}.info Temperature of {name} ({model}) print("""disk{disk_id}.info Temperature of {name} ({model})
disk{disk_id}.label {name} ({model}) disk{disk_id}.label {name} ({model})
disk{disk_id}.type GAUGE disk{disk_id}.type GAUGE
disk{disk_id}.min 0""".format(disk_id=id, name=name, model=model) disk{disk_id}.min 0""".format(disk_id=id, name=name, model=model))
print """multigraph synology_sys_temperature print("""multigraph synology_sys_temperature
host_name {hostname} host_name {hostname}
graph_title System temperatures of {hostname} graph_title System temperatures of {hostname}
graph_vlabel Temperature in °C graph_vlabel Temperature in °C
@ -144,15 +144,15 @@ sys_temp.info System temperature
sys_temp.label Temperature sys_temp.label Temperature
sys_temp.type GAUGE sys_temp.type GAUGE
sys_temp.min 0 sys_temp.min 0
""".format(hostname=self.hostname) """.format(hostname=self.hostname))
def execute(self): def execute(self):
print """multigraph synology_hdd_temperatures""" print("""multigraph synology_hdd_temperatures""")
for id, name, model, temp in self._get_disks(): for id, name, model, temp in self._get_disks():
print """disk{disk_id}.value {temp}""".format(disk_id=id, temp=temp) print("""disk{disk_id}.value {temp}""".format(disk_id=id, temp=temp))
print """multigraph synology_sys_temperature""" print("""multigraph synology_sys_temperature""")
print "sys_temp.value {temp}".format(temp=self._get_sys_temperature()) print("sys_temp.value {temp}".format(temp=self._get_sys_temperature()))
host = None host = None
@ -175,7 +175,7 @@ except Exception as ex:
if "snmpconf" in sys.argv[1:]: if "snmpconf" in sys.argv[1:]:
print "require 1.3.6.1.4.1.6574.2.1.1" print("require 1.3.6.1.4.1.6574.2.1.1")
sys.exit(0) sys.exit(0)
else: else:
if not (host and port and community): if not (host and port and community):

View file

@ -300,8 +300,8 @@ def print_config(mode):
"graph_info This graph shows the number of connections used by Deluge Torrent") "graph_info This graph shows the number of connections used by Deluge Torrent")
print(names_for_munin["numConnections"] + ".label connections") print(names_for_munin["numConnections"] + ".label connections")
print(names_for_munin["numConnections"] + ".min 0") print(names_for_munin["numConnections"] + ".min 0")
print(names_for_munin["numConnections"] + print(names_for_munin["numConnections"]
".info The number of connections used by Deluge Torrent") + ".info The number of connections used by Deluge Torrent")
elif mode == "bandwidth": elif mode == "bandwidth":
print("graph_title Bandwidth usage") print("graph_title Bandwidth usage")
print("graph_order payloadDownloadRate overheadDownloadRate payloadUploadRate " print("graph_order payloadDownloadRate overheadDownloadRate payloadUploadRate "
@ -353,13 +353,12 @@ def print_config(mode):
print("graph_period second") print("graph_period second")
for state_name in torrent_states: for state_name in torrent_states:
print(names_for_munin["state." + print(names_for_munin["state." + state_name] + ".label " + state_name)
state_name] + ".label " + state_name)
print(names_for_munin["state." + state_name] + ".draw AREASTACK") print(names_for_munin["state." + state_name] + ".draw AREASTACK")
print(names_for_munin["state." + state_name] + ".type GAUGE") print(names_for_munin["state." + state_name] + ".type GAUGE")
print(names_for_munin["state." + state_name] + ".min 0") print(names_for_munin["state." + state_name] + ".min 0")
print(names_for_munin["state." + state_name] + print(names_for_munin["state." + state_name]
".info Number of torrents in the '" + state_name + "' state") + ".info Number of torrents in the '" + state_name + "' state")
def fetch_info(mode): def fetch_info(mode):

View file

@ -3,7 +3,7 @@
import os import os
import re import re
import sys import sys
import urllib from urllib.request import urlopen
url = 'http://www.weather.com/weather/today/%s' url = 'http://www.weather.com/weather/today/%s'
@ -19,7 +19,7 @@ if not code:
elif len(sys.argv) == 2 and sys.argv[1] == "autoconf": elif len(sys.argv) == 2 and sys.argv[1] == "autoconf":
print("yes") print("yes")
elif len(sys.argv) == 2 and sys.argv[1] == "config": elif len(sys.argv) == 2 and sys.argv[1] == "config":
u = urllib.urlopen(url % code) u = urlopen(url % code)
txt = u.read() txt = u.read()
u.close() u.close()
@ -39,7 +39,7 @@ elif len(sys.argv) == 2 and sys.argv[1] == "config":
print('graph_args --base 1000 -l 0') print('graph_args --base 1000 -l 0')
else: else:
u = urllib.urlopen(url % code) u = urlopen(url % code)
txt = u.read() txt = u.read()
u.close() u.close()