WMI Query to get disk error count

Started by BillLortz, January 22, 2016, 10:34:45 PM

Previous topic - Next topic

BillLortz

Just in case it would be helpful to someone else, I'm posting the WMI Query I use to get the total number of disk errors for my hard drive.  I have a system that I stumbled on that had a disk that was failing.   I found the SMART Data was fairly useless, but Windows has a special class that gave me the data I was interested in - MSFT_StorageReliabilityCounter.   If you google it, you'll see that it has a bunch of useful info.   I decided that ReadErrorsTotal would be a good indicator of a problem drive.

Unfortunately, the query tended to return two entries for a given DeviceID that were almost identical, so I arbitrarily chose the one that ended with the text "reliabilitycounter".   The other one on my system had some sort of SCSI Id that I wasn't sure would be consistent.   On my system without any "where" clause, the query returns 4 entries - two for DeviceId 0 and two for DeviceId 1.   I'm assuming those correspond to physical drives 0 and 1.   If you want to monitor another drive instead of 0, just change the "0" in the "Where" statement to the other drive number.   You could have multiple queries, one for each drive on your system.

WMI.Query(root\microsoft\windows\storage,SELECT * FROM MSFT_StorageReliabilityCounter where '(DeviceId=0) AND (ObjectID like "%reliabilitycounter")',ReadErrorsTotal)


This query returns an unsigned 64 bit integer.   I have the frequency set to 3600 seconds and 90 days of history in NetXMS.

I hope this helps someone so that they don't have to go through hours of research to get this data, and they don't waste too much time trying to use the SMART data which declared my drive that has 4248 total read errors as perfectly fine - even though it is barely functioning.