1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

raid2: use perlpod and small fixes

This commit is contained in:
Kim B. Heino 2021-04-06 10:26:54 +03:00 committed by Lars Kruse
parent d3bcc2f9bf
commit 558360c412

View file

@ -1,13 +1,36 @@
#!/usr/bin/python3 -tt
# -*- coding: utf-8 -*-
#!/usr/bin/env python3
"""Munin plugin to monitor software and hardware RAID status and scrub status.
"""Munin plugin to monitor software and hardware RAID and scrub status.
Copyright 2014 Kim B. Heino, Foobar Oy
License GPLv2+
=head1 NAME
#%# capabilities=autoconf
#%# family=auto
raid - monitor software and hardware RAID and scrub status
=head1 APPLICABLE SYSTEMS
Linux systems with mdraid, btrfs, cciss or megasasctl RAID.
=head1 CONFIGURATION
Following config is needed:
[raid]
user root
=head1 AUTHOR
Kim B. Heino <b@bbbs.net>
=head1 LICENSE
GPLv2
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
"""
import glob
@ -17,17 +40,11 @@ import subprocess
import sys
def safename(variable):
def safename(name):
"""Return safe variable name."""
if variable == '/':
return 'btrfs'
ret = []
for letter in variable:
if letter.isalnum():
ret.append(letter)
else:
ret.append('_')
return ''.join(ret)
if name == '/':
return 'root'
return ''.join(char.lower() if char.isalnum() else '_' for char in name)
def run_binary(arg):
@ -82,7 +99,7 @@ def find_megasasctl():
return []
# Run binary
data = run_binary(['/usr/sbin/megasasctl', '-HB'])
data = run_binary([statexe, '-HB'])
if data:
status = 0
else:
@ -161,12 +178,6 @@ def find_devices():
return devices
def autoconf():
"""Print "yes" or "no"."""
status = 'yes' if find_devices() else 'no'
print(status)
def config(devices):
"""Print plugin config."""
print('graph_title RAID and Scrub Status')
@ -189,7 +200,7 @@ def fetch(devices):
if __name__ == '__main__':
if len(sys.argv) > 1 and sys.argv[1] == 'autoconf':
autoconf()
print('yes' if find_devices() else 'no (no RAID devices found)')
elif len(sys.argv) > 1 and sys.argv[1] == 'config':
config(find_devices())
else: