Check Apple RAIDs and email when there is a problem
This script can be used in a cron which runs every 5 or 10 minutes and will email as soon as it detects an issue with an Apple RAID.
I am working on an Apple XServe RAID checker, but this one will handle internal drive bay RAIDs.
#!/usr/bin/env python
import os
import string
import smtplib
from socket import gethostname
smtpserver = 'localhost'
smtpfrom = gethostname() + '@localhost'
smtpto = ['##EMAIL_OF_RECIPIENT##']
raidstatus = os.popen('/usr/sbin/diskutil listRaid')
status = raidstatus.read()
raidstatus.close()
if status.find('Degraded') > -1:
smtpsubject = 'WARNING - Raid degraded on ' + gethostname()
smtp = smtplib.SMTP(smtpserver)
message = """\
From: %s
To: %s
Subject: %s
%s
""" % (smtpfrom, ", ".join(smtpto), smtpsubject, status)
smtp.sendmail(smtpfrom, smtpto, message)
smtp.quit()