in progress
This commit is contained in:
parent
362710ffa8
commit
4ee5939b13
490 changed files with 14041 additions and 0 deletions
45
roles/nagios_server/files/plugins/check_raid.py
Executable file
45
roles/nagios_server/files/plugins/check_raid.py
Executable file
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# very simple python script to parse out /proc/mdstat
|
||||
# and give results for nagios to monitor
|
||||
#
|
||||
|
||||
import sys
|
||||
import string
|
||||
|
||||
devices = []
|
||||
|
||||
try:
|
||||
mdstat = string.split(open('/proc/mdstat').read(), '\n')
|
||||
except IOError:
|
||||
# seems we have no software raid on this machines
|
||||
sys.exit(0)
|
||||
|
||||
error = ""
|
||||
i = 0
|
||||
for line in mdstat:
|
||||
if line[0:2] == 'md':
|
||||
device = string.split(line)[0]
|
||||
devices.append(device)
|
||||
status = string.split(mdstat[i+1])[3]
|
||||
if string.count(status, "_"):
|
||||
# see if we can figure out what's going on
|
||||
err = string.split(mdstat[i+2])
|
||||
msg = "device=%s status=%s" % (device, status)
|
||||
if len(err) > 0:
|
||||
msg = msg + " rebuild=%s" % err[0]
|
||||
|
||||
if not error:
|
||||
error = msg
|
||||
else:
|
||||
error = error + ", " + msg
|
||||
i = i + 1
|
||||
|
||||
if not error:
|
||||
print "DEVICES %s OK" % " ".join(devices)
|
||||
sys.exit(0)
|
||||
|
||||
else:
|
||||
print error
|
||||
sys.exit(2)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue