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

Fix linting issues.

This commit is contained in:
HaseHarald 2020-08-24 21:37:29 +02:00
parent 675dedf1d4
commit bffbc23a4e
2 changed files with 36 additions and 36 deletions

View file

@ -1,4 +1,4 @@
#!/usr/bin/python3 #!/usr/bin/env python3
# #
# This file contains a munin-plugin to gather btrfs statistics per device. # This file contains a munin-plugin to gather btrfs statistics per device.
# #
@ -28,7 +28,7 @@ def munin_config(fs):
print("graph_title btrfs total device stats for " + fs.path) print("graph_title btrfs total device stats for " + fs.path)
print("graph_category disk") print("graph_category disk")
print("graph_info This graph shows the total stats of devices used by btrfs") print("graph_info This graph shows the total stats of devices used by btrfs")
print("corruption_errs_total.label Corruption Errors") print("corruption_errs_total.label Corruption Errors")
print("flush_errs_total.label Flush Errors") print("flush_errs_total.label Flush Errors")
print("generation_errs_total.label Generation Errors") print("generation_errs_total.label Generation Errors")
@ -36,9 +36,9 @@ def munin_config(fs):
print("write_errs_total.label Write Errors") print("write_errs_total.label Write Errors")
print("nr_items_total.label Nr. of Items") print("nr_items_total.label Nr. of Items")
print("flags_total.label Nr. of Flags") print("flags_total.label Nr. of Flags")
print("") print("")
devices = fs.devices() devices = fs.devices()
for this_device in devices: for this_device in devices:
this_dev_info = fs.dev_info(this_device.devid) this_dev_info = fs.dev_info(this_device.devid)
@ -49,7 +49,7 @@ def munin_config(fs):
print("graph_title btrfs device stats for " + this_dev_name) print("graph_title btrfs device stats for " + this_dev_name)
print("graph_category disk") print("graph_category disk")
print("graph_info This graph shows stats of devices used by btrfs") print("graph_info This graph shows stats of devices used by btrfs")
print("corruption_errs.label Corruption Errors") print("corruption_errs.label Corruption Errors")
print("corruption_errs.warming 1") print("corruption_errs.warming 1")
print("flush_errs.label Flush Errors") print("flush_errs.label Flush Errors")
@ -63,7 +63,7 @@ def munin_config(fs):
print("nr_items.label Nr. of Items") print("nr_items.label Nr. of Items")
print("flags.label Nr. of Flags") print("flags.label Nr. of Flags")
print("flags.warming 1") print("flags.warming 1")
print("") print("")
@ -75,13 +75,13 @@ def munin_values(fs):
write_errs_total = 0 write_errs_total = 0
nr_items_total = 0 nr_items_total = 0
flags_total = 0 flags_total = 0
fsid = str(fs.fsid).replace('-', '_') fsid = str(fs.fsid).replace('-', '_')
devices = fs.devices() devices = fs.devices()
for this_device in devices: for this_device in devices:
this_dev_stat = fs.dev_stats(this_device.devid, False) this_dev_stat = fs.dev_stats(this_device.devid, False)
corruption_errs = this_dev_stat.corruption_errs corruption_errs = this_dev_stat.corruption_errs
flush_errs = this_dev_stat.flush_errs flush_errs = this_dev_stat.flush_errs
generation_errs = this_dev_stat.generation_errs generation_errs = this_dev_stat.generation_errs
@ -89,7 +89,7 @@ def munin_values(fs):
write_errs = this_dev_stat.write_errs write_errs = this_dev_stat.write_errs
nr_items = this_dev_stat.nr_items nr_items = this_dev_stat.nr_items
flags = this_dev_stat.flags flags = this_dev_stat.flags
corruption_errs_total = corruption_errs_total + corruption_errs corruption_errs_total = corruption_errs_total + corruption_errs
flush_errs_total = flush_errs_total + flush_errs flush_errs_total = flush_errs_total + flush_errs
generation_errs_total = generation_errs_total + generation_errs generation_errs_total = generation_errs_total + generation_errs
@ -97,9 +97,9 @@ def munin_values(fs):
write_errs_total = write_errs_total + write_errs write_errs_total = write_errs_total + write_errs
nr_items_total = nr_items_total + nr_items nr_items_total = nr_items_total + nr_items
flags_total = flags_total + flags flags_total = flags_total + flags
print("multigraph btrfs_device_stats_" + fsid + "." + str(this_device.devid)) print("multigraph btrfs_device_stats_" + fsid + "." + str(this_device.devid))
print("corruption_errs.value " + str(corruption_errs)) print("corruption_errs.value " + str(corruption_errs))
print("flush_errs.value " + str(flush_errs)) print("flush_errs.value " + str(flush_errs))
print("generation_errs.value " + str(generation_errs)) print("generation_errs.value " + str(generation_errs))
@ -107,11 +107,11 @@ def munin_values(fs):
print("write_errs.value " + str(write_errs)) print("write_errs.value " + str(write_errs))
print("nr_items.value " + str(nr_items)) print("nr_items.value " + str(nr_items))
print("flags.value " + str(flags)) print("flags.value " + str(flags))
print("") print("")
print("multigraph btrfs_device_stats_" + fsid) print("multigraph btrfs_device_stats_" + fsid)
print("corruption_errs_total.value " + str(corruption_errs_total)) print("corruption_errs_total.value " + str(corruption_errs_total))
print("flush_errs_total.value " + str(flush_errs_total)) print("flush_errs_total.value " + str(flush_errs_total))
print("generation_errs_total.value " + str(generation_errs_total)) print("generation_errs_total.value " + str(generation_errs_total))
@ -119,7 +119,7 @@ def munin_values(fs):
print("write_errs_total.value " + str(write_errs_total)) print("write_errs_total.value " + str(write_errs_total))
print("nr_items_total.value " + str(nr_items_total)) print("nr_items_total.value " + str(nr_items_total))
print("flags_total.value " + str(flags_total)) print("flags_total.value " + str(flags_total))
print("") print("")

View file

@ -1,4 +1,4 @@
#!/usr/bin/python3 #!/usr/bin/env python3
# #
# This file contains a munin-plugin to gather btrfs statistics per device. # This file contains a munin-plugin to gather btrfs statistics per device.
# #
@ -22,7 +22,7 @@ import sys
def munin_config(fs): def munin_config(fs):
fsid = str(fs.fsid).replace('-', '_') fsid = str(fs.fsid).replace('-', '_')
print("multigraph btrfs_device_usage_byte_" + fsid) print("multigraph btrfs_device_usage_byte_" + fsid)
print("graph_title btrfs usage by device in bytes on " + fs.path) print("graph_title btrfs usage by device in bytes on " + fs.path)
print("graph_args --base 1024 -l 0") print("graph_args --base 1024 -l 0")
@ -30,16 +30,16 @@ def munin_config(fs):
print("graph_vlabel bytes") print("graph_vlabel bytes")
print("graph_category disk") print("graph_category disk")
print("graph_info This graph shows bytes used by btrfs on every device") print("graph_info This graph shows bytes used by btrfs on every device")
devices = fs.devices() devices = fs.devices()
for this_device in devices: for this_device in devices:
this_dev_info = fs.dev_info(this_device.devid) this_dev_info = fs.dev_info(this_device.devid)
this_dev_name = this_dev_info.path.replace('/dev/', '') this_dev_name = this_dev_info.path.replace('/dev/', '')
print("btrfs_bytes_" + fsid + "_" + str(this_device.devid) + print("btrfs_bytes_" + fsid + "_" + str(this_device.devid) +
".label " + this_dev_name) ".label " + this_dev_name)
print("") print("")
print("multigraph btrfs_device_usage_percent_" + fsid) print("multigraph btrfs_device_usage_percent_" + fsid)
print("graph_title btrfs usage by device in percent on " + fs.path) print("graph_title btrfs usage by device in percent on " + fs.path)
print("graph_args --base 1000 -l 0") print("graph_args --base 1000 -l 0")
@ -47,46 +47,46 @@ def munin_config(fs):
print("graph_vlabel %") print("graph_vlabel %")
print("graph_category disk") print("graph_category disk")
print("graph_info This graph shows percentage used by btrfs on every \ print("graph_info This graph shows percentage used by btrfs on every \
device. Maesured in percentage of device capacity.") device. Maesured in percentage of device capacity.")
devices = fs.devices() devices = fs.devices()
for this_device in devices: for this_device in devices:
this_dev_info = fs.dev_info(this_device.devid) this_dev_info = fs.dev_info(this_device.devid)
this_dev_name = this_dev_info.path.replace('/dev/', '') this_dev_name = this_dev_info.path.replace('/dev/', '')
print("btrfs_percent_" + fsid + "_" + str(this_device.devid) + print("btrfs_percent_" + fsid + "_" + str(this_device.devid) +
".label " + this_dev_name) ".label " + this_dev_name)
print("btrfs_percent_" + fsid + "_" + str(this_device.devid) + ".warning 95") print("btrfs_percent_" + fsid + "_" + str(this_device.devid) + ".warning 95")
print("btrfs_percent_" + fsid + "_" + str(this_device.devid) + ".critical 98") print("btrfs_percent_" + fsid + "_" + str(this_device.devid) + ".critical 98")
print("") print("")
def munin_values(fs): def munin_values(fs):
fsid = str(fs.fsid).replace('-', '_') fsid = str(fs.fsid).replace('-', '_')
devices = fs.devices() devices = fs.devices()
print("multigraph btrfs_device_usage_byte_" + fsid) print("multigraph btrfs_device_usage_byte_" + fsid)
for this_device in devices: for this_device in devices:
this_dev_info = fs.dev_info(this_device.devid) this_dev_info = fs.dev_info(this_device.devid)
print("btrfs_bytes_" + fsid + "_" + str(this_device.devid) + print("btrfs_bytes_" + fsid + "_" + str(this_device.devid) +
".value " + str(this_dev_info.bytes_used)) ".value " + str(this_dev_info.bytes_used))
print("") print("")
# Reset device iterator # Reset device iterator
devices = fs.devices() devices = fs.devices()
print("multigraph btrfs_device_usage_percent_" + fsid) print("multigraph btrfs_device_usage_percent_" + fsid)
for this_device in devices: for this_device in devices:
this_dev_info = fs.dev_info(this_device.devid) this_dev_info = fs.dev_info(this_device.devid)
usage = 100.0 * this_dev_info.bytes_used / this_dev_info.total_bytes usage = 100.0 * this_dev_info.bytes_used / this_dev_info.total_bytes
print("btrfs_percent_" + fsid + "_" + str(this_device.devid) + print("btrfs_percent_" + fsid + "_" + str(this_device.devid) +
".value " + str(round(usage, 2))) ".value " + str(round(usage, 2)))
print("") print("")
def main(): def main():
for path in btrfs.utils.mounted_filesystem_paths(): for path in btrfs.utils.mounted_filesystem_paths():