You don't want to pay for an iLO subscription but still want to be warned if one of your RAID drive was to fail, this script is made for you!
- Python 3
- SSACLI (from Windows Server Service Pack)
python3 check-drives.py
#!python | |
import subprocess | |
import re | |
import smtplib | |
from email.message import EmailMessage | |
def send_email(): | |
mail = EmailMessage() | |
mail.set_content('At least one disk is in a failed state', subtype='html') | |
mail['Subject'] = 'Server - Disk error' | |
mail['From'] = '[email protected]' | |
mail['To'] = '[email protected]' | |
with smtplib.SMTP('<SMTP URL>', port='587') as smtp: | |
smtp.login('<SMTP login>', '<SMTP password>') | |
smtp.send_message(mail) | |
drive_regex = re.compile('physicaldrive [^ ]+ \(.+, (.+?)\)') | |
process = subprocess.check_output('do-check-drives.bat') | |
drive_results = drive_regex.findall(process.decode()) | |
success = True | |
for drive_result in drive_results: | |
if drive_result != 'OK': | |
success = False | |
if success: | |
print('Everything is fine (%s disks checked)' % len(drive_results)) | |
else: | |
print('At least one disk is in a failed state, sending warning email') | |
send_email() |
"C:\Program Files\Smart Storage Administrator\ssacli\bin\ssacli.exe" controller slot=0 physicaldrive all show |