Get SMART status of disk drive

Hi all,

Please use below script to get SMART status of hard disk,


import os
command = "wmic diskdrive get Status"
out=os.popen(command).read()
print (out) 

Sample output would be,

Status
OK
OK

20170213-Check-SMART-Status-of-the-Hard-disk.json (398 Bytes)

I am curious what conditions will make this fail?? I looked the script over, and do not see where it will fail, if something doesn’t come back OK, so we could trigger an alert, I feel this would be more relevant, and useful, if we could use the procedure to kick off alerts, and create tickets. Thanks.

Hi @BOSS

I am curious what conditions will make this fail?? I looked the script over, and do not see where it will fail, if something doesn’t come back OK, so we could trigger an alert, I feel this would be more relevant, and useful, if we could use the procedure to kick off alerts, and create tickets. Thanks.

Please refer below procedure which fails if status changed from “OK” :slight_smile:


import os
command = "wmic diskdrive get Status"
out=os.popen(command).readlines()
count=0

for j in out:
        print j

if out[1]!='OK      
':
    raise Exception('Disk SMART status changed from "OK"')



Thanks,
Kannan

20170309-Get-SMART–status-of-disk-drive-and-Raise-error-if-status-not-OK.json (602 Bytes)

Will Comodo itself create ticket alerts if smart fails? Or can this be run scheduled to check for that?

Hi @ indieserve

More likely it would be a schedule. Please refer to this link for creating custom procedures, and creating alerts.

https://help.comodo.com/topic-399-1-786-10976-Create-a-Custom-Procedure.html
https://help.comodo.com/topic-399-1-786-10973-Create-a-New-Alert.html

I have mine set up as an auto remediation procedure, when my monitors find certain disk errors, it runs this, then I look in the logs to check the status. Works great, as I am manually looking at systems that that trip monitor alerts anyway. I do not just run it on a schedule, as I do not feel the need, unless my monitors catch a disk error, like a disk error 52. The great thing about comodo one, is that it can be customized in many ways, auto remediation really helps make my job easier, for example, when my CPU usages gets too high, it automatically runs the check last five highest running processes. Then, I look in the logs, that way I have a snapshot of when it happened, so I have an idea of where to look, instead of trying to catch it with the issue. We all know how difficult it can be to catch the system in a 5-15 minute period, while it is acting up.