S.M.A.R.T. (Self-Monitoring, Analysis and Reporting Technology; written as SMART) SMART is a system for monitoring and early detection of errors of storage media such as hard disks or SSDs.
NOTE:Run IDE as administrator and SMARTMONTOOLS should be installed in the system
IMPLEMENTATION:
import os
classSMART:def__init__(self):
self.deviceList=list()
#to run a smartctl commanddefRunSmartCtl(self, strArgs):#get the command with strArgs as the argument
cmdString = "smartctl " + strArgs
#get command output and store each line in a list
output = os.popen(cmdString).read()
lines = str.splitlines(output)
return lines
#to obtain all device idsdefGetDeviceIds(self):
lines = self.RunSmartCtl("--scan")
for line in lines:
deviceId = str.split(line, " " ,1)[0]
self.deviceList.append(deviceId)
#function to display deviceID'sdefdisplayDeviceID(self):
print("Device ID's are:")
i=1for id in self.deviceList:
print(i,id)
i=i+1defmain():
smart_features = SMART()
smart_features.GetDeviceIds()
smart_features.displayDeviceID()
if __name__ == '__main__':
main()
Comments