mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 02:51:03 +00:00
raid2: use perlpod and small fixes
This commit is contained in:
parent
d3bcc2f9bf
commit
558360c412
1 changed files with 36 additions and 25 deletions
|
@ -1,13 +1,36 @@
|
||||||
#!/usr/bin/python3 -tt
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
"""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
|
=head1 NAME
|
||||||
License GPLv2+
|
|
||||||
|
|
||||||
#%# capabilities=autoconf
|
raid - monitor software and hardware RAID and scrub status
|
||||||
#%# family=auto
|
|
||||||
|
=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
|
import glob
|
||||||
|
@ -17,17 +40,11 @@ import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def safename(variable):
|
def safename(name):
|
||||||
"""Return safe variable name."""
|
"""Return safe variable name."""
|
||||||
if variable == '/':
|
if name == '/':
|
||||||
return 'btrfs'
|
return 'root'
|
||||||
ret = []
|
return ''.join(char.lower() if char.isalnum() else '_' for char in name)
|
||||||
for letter in variable:
|
|
||||||
if letter.isalnum():
|
|
||||||
ret.append(letter)
|
|
||||||
else:
|
|
||||||
ret.append('_')
|
|
||||||
return ''.join(ret)
|
|
||||||
|
|
||||||
|
|
||||||
def run_binary(arg):
|
def run_binary(arg):
|
||||||
|
@ -82,7 +99,7 @@ def find_megasasctl():
|
||||||
return []
|
return []
|
||||||
|
|
||||||
# Run binary
|
# Run binary
|
||||||
data = run_binary(['/usr/sbin/megasasctl', '-HB'])
|
data = run_binary([statexe, '-HB'])
|
||||||
if data:
|
if data:
|
||||||
status = 0
|
status = 0
|
||||||
else:
|
else:
|
||||||
|
@ -161,12 +178,6 @@ def find_devices():
|
||||||
return devices
|
return devices
|
||||||
|
|
||||||
|
|
||||||
def autoconf():
|
|
||||||
"""Print "yes" or "no"."""
|
|
||||||
status = 'yes' if find_devices() else 'no'
|
|
||||||
print(status)
|
|
||||||
|
|
||||||
|
|
||||||
def config(devices):
|
def config(devices):
|
||||||
"""Print plugin config."""
|
"""Print plugin config."""
|
||||||
print('graph_title RAID and Scrub Status')
|
print('graph_title RAID and Scrub Status')
|
||||||
|
@ -189,7 +200,7 @@ def fetch(devices):
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if len(sys.argv) > 1 and sys.argv[1] == 'autoconf':
|
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':
|
elif len(sys.argv) > 1 and sys.argv[1] == 'config':
|
||||||
config(find_devices())
|
config(find_devices())
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue