Alerts if health status changes in S.M.A.R.T status of hard drives


This script will help you to view your hard drive’s S.M.A.R.T(Self-Monitoring, Analysis, and Reporting Technology) data.

script generates the alerts if any of the condition is met i.e (Health status is " Failed ", Temperature is high and changes in Attribute conditions of Hard Drive)

Note: This script uses the open source smart monitoring tool.

This Script should run as Custom monitoring for better output

import urllib
import os
import sys
import re
def alert(arg):
 sys.stderr.write("%d%d%d" % (arg, arg, arg))
def information(workdir):
    out=os.popen("smartctl -a /dev/sda").read()

    for i in out:
        if 'Read SMART Log Directory failed:' in i:
    if 'SMART support is: Available - device has SMART capability.' in out:
            print "SMART Support is Available"
    if 'SMART support is: Enabled' in out :
            print "SMART support is enabled"
    if 'SMART support is: Disabled ' in out :
            print 'SMART support is disabled it is Enabling  '
            os.popen('smartctl -s on /dev/sda')
            print "SMART SUPPORT is Enabled"

    if 'SMART overall-health self-assessment test result: PASSED' in out:
            print "Health status Passed"
    else :
            print "*****"
            print "Health status is Failed"
    out1=os.popen('smartctl -A /dev/sda').read()
    li1=[int(s) for s in reg[0].split() if s.isdigit()]
    if li1[le-1]>0:
            print "*****"
            print "Please check hard drive"
            print reg[0]
    else :
        print "Offline Uncorrectable Attribute is passed "
    li1=[int(s) for s in reg[0].split() if s.isdigit()]
    if li1[le-1]>0:
            print "*****"
            print "Please check hard drive"
            print reg[0]

    else :
        print "Current Pending Sector Attribute is Passed"
    li1=[int(s) for s in reg[0].split() if s.isdigit()]
    if li1[le-1]> 29 and li1[le-1] < 45:
            print "Temperature of Hard drive is " +str(li1[le-1])
            print "*****"
            print "Temperature of Hard drive is " +str(li1[le-1])
            print "Temperature is too High"
    print "
    print out

    if ale>0:
    else :
            print "Your HARD DISK is safe"
def downloadFile(DownTo, fromURL):
  fileName = fromURL.split('/')[-1]
  DownTo = os.path.join(DownTo, fileName)
  with open(DownTo, 'wb') as f:
  if os.path.isfile(DownTo):
   return '{} - {}KB'.format(DownTo, os.path.getsize(DownTo)/1000)
  return 'Please Check URL or Download Path!'

if not os.path.isdir(workdir):
url=' Force Deleter/x86/smartctl.exe'
if not os.path.exists(workdir+r'\smartctl.exe'):
    print "The tool is downloading"

20170630-Imported-SMART-Hard-Drive-monitoring.json (4.38 KB)

Hi Guys,

the script has a bit of a flaw with it.

The following line means all HDDs are too hot
if li1[le-1]> 29 and li1[le-1] < 45: i have changed the 29 to a 0 for us for now, but if you want to make the script better a switch/case if python allows with below say 15 being too cold?

Hi @StrobeTech
Thank you for the suggestion. We will make sure that your suggestion reaches the attention of the script development team.

I have tested, and thanks for this script! works fine, but I have an issue.

When I run this script on Hyperv (microsoft) if I have a hard disk offline (attached on virtual machine) the scripts returns an error and create an alert (failed) how can we change to ignore or read the offline disks?


We understand that you have some additional setups that you are testing the procedure. We will forward the result of your test to our Script Developers and get recommendation for any modifications that need to be made.

@ftsolucoes ,

We thank you for sharing the output of your test. We’ll make sure to have this result shared to ur Script Developers.


Hello @ftsolucoes

We are glad to help you here. Kindly refer this script which will return you the Health status of all Hard disks available in your server :

As shown on image, if you receive that “Health Status is Failed”, it means you need to enable it in your server setup. Enter into BIOS setup, enable SMART then run this script. Hope it make better sense.

Thank you.