Skip to content

Instantly share code, notes, and snippets.

@pimpreneil
Created September 16, 2022 13:24
Show Gist options
  • Save pimpreneil/5c3b26a419a2ea01e721b3038e12cae6 to your computer and use it in GitHub Desktop.
Save pimpreneil/5c3b26a419a2ea01e721b3038e12cae6 to your computer and use it in GitHub Desktop.
Detect disk failures from HPE Smart Storage Administrator

Introduction

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!

Prerequisites

  • Python 3
  • SSACLI (from Windows Server Service Pack)

Execution

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'] = 'example@example.com'
mail['To'] = 'example@example.com'
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment