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

Plugin snmp__synology: fix code style issues reported by flake8

This commit is contained in:
Lars Kruse 2019-08-14 00:02:40 +02:00
parent 8b69c8a1fe
commit dacb55010a
2 changed files with 76 additions and 74 deletions

View file

@ -63,6 +63,7 @@ disktable_model = '1.3.6.1.4.1.6574.2.1.1.3'
disktable_temp = '1.3.6.1.4.1.6574.2.1.1.6' disktable_temp = '1.3.6.1.4.1.6574.2.1.1.6'
sys_temperature = '1.3.6.1.4.1.6574.1.2.0' sys_temperature = '1.3.6.1.4.1.6574.1.2.0'
class SynologySNMPClient(object): class SynologySNMPClient(object):
def __init__(self, host, port, community): def __init__(self, host, port, community):
self.hostname = host self.hostname = host
@ -79,7 +80,8 @@ class SynologySNMPClient(object):
disk_table) disk_table)
if errorIndication: if errorIndication:
logging.error("SNMP bulkCmd for devices failed: %s, %s, %s" % (errorIndication, errorStatus, errorIndex)) logging.error("SNMP bulkCmd for devices failed: %s, %s, %s",
errorIndication, errorStatus, errorIndex)
return return
devices = {} devices = {}
@ -110,7 +112,8 @@ class SynologySNMPClient(object):
sys_temperature) sys_temperature)
if errorIndication: if errorIndication:
logging.error("SNMP getCmd for %s failed: %s, %s, %s" % (sys_temperature, errorIndication, errorStatus, errorIndex)) logging.error("SNMP getCmd for %s failed: %s, %s, %s",
sys_temperature, errorIndication, errorStatus, errorIndex)
return None return None
return int(varBindTable[0][1]) return int(varBindTable[0][1])
@ -130,7 +133,6 @@ 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}
@ -162,9 +164,9 @@ if debug:
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-7s %(message)s') logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-7s %(message)s')
try: try:
match = re.search("^(?:|.*\/)snmp_([^_]+)_synology$", sys.argv[0]) match = re.search(r"^(?:|.*\/)snmp_([^_]+)_synology$", sys.argv[0])
host = match.group(1) host = match.group(1)
match = re.search("^([^:]+):(\d+)$", host) match = re.search(r"^([^:]+):(\d+)$", host)
if match is not None: if match is not None:
host = match.group(1) host = match.group(1)
port = match.group(2) port = match.group(2)
@ -177,7 +179,8 @@ if "snmpconf" in sys.argv[1:]:
sys.exit(0) sys.exit(0)
else: else:
if not (host and port and community): if not (host and port and community):
print "# Bad configuration. Cannot run with Host=%s, port=%s and community=%s" % (host, port, community) print("# Bad configuration. Cannot run with Host=%s, port=%s and community=%s"
% (host, port, community))
sys.exit(1) sys.exit(1)
c = SynologySNMPClient(host, port, community) c = SynologySNMPClient(host, port, community)

View file

@ -431,7 +431,6 @@ plugins/streaming/packetship_
plugins/swift/swift-async_ plugins/swift/swift-async_
plugins/swift/swift-quarantined_ plugins/swift/swift-quarantined_
plugins/swift/swift-replication-time_ plugins/swift/swift-replication-time_
plugins/synology/snmp__synology
plugins/system/auth plugins/system/auth
plugins/system/blockhosts plugins/system/blockhosts
plugins/systemd/systemd_units plugins/systemd/systemd_units