windows_exporter icon indicating copy to clipboard operation
windows_exporter copied to clipboard

diskdrive collector (windows_diskdrive_availability)

Open Sixty502 opened this issue 1 year ago • 5 comments

Problem Statement

In looking at the diskdrive collector, I tried to see if I could use windows_diskdrive_availability to find problems. On the machines I've looked at, the values are aways zero. When I look at win32_diskdrive for any of my disks, Availability, which appears to be where the information comes from, is always NULL.

MSFT_Disk (Get-WmiObject -Class MSFT_Disk -Namespace root\Microsoft\Windows\Storage |select *) seems to provide more information. OfflineReason and OperationalStatus have values that indicate the status of the drive(s).

I'm not sure if there is an issue with the information in windows_diskdrive_availability or if I need a better way to test and make the values change.

Environment

  • windows_exporter Version: 0.28.0
  • Windows Server Version: WS19,WS22

Sixty502 avatar Sep 05 '24 04:09 Sixty502

Yes I can confirm that Availability isn't always provided. The windows_exporter uses this call to gather the info:

SELECT DeviceID, Model, Caption, Name, Partitions, Size, Status, Availability FROM WIN32_DiskDrive

It seems that Availability is not always there. It depends maybe on disk kind or win version. I tested this with:

Get-WmiObject -Query "SELECT Availability FROM WIN32_DiskDrive"

on some machines and it returned always nothing.

In the exporter, if nothing is returned, the variable disk.Availability is 0 and it can never set the isCurrentState to 1 since availMap starts with 1 and has no 0 entry

https://github.com/prometheus-community/windows_exporter/blob/50687655bffefeba3f3bce6e24dbc18ffbf12fea/pkg/collector/diskdrive/diskdrive.go#L223-L235

EDIT:

If someone can maybe confirm that on some machines Availability is returned, cos it is actually in the ms docs: https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-diskdrive#properties

  • If yes I'd say that availMap should have a state 0 with a value set maybe "not implemented" or something.
  • If no or it is very rare that a value is returned I'd say that Availability should be removed from the exporter.

DiniFarb avatar Sep 05 '24 12:09 DiniFarb

I looked at a few more machines and didn't find one with Availability populated. It seems like it should default to 6 (Not Applicable) and not NULL.

Sixty502 avatar Sep 10 '24 03:09 Sixty502

I feel that current behavior is fine. If windows report no value, the exporter should not fake a value.

jkroepke avatar Sep 11 '24 06:09 jkroepke

I was thinking about what Windows is reporting. I wouldn't want exporter or Windows making something up. Whatever should be providing the information isn't. Null is one way for them to handle it, but it seems like Unknown (2) or Not Applicable (6) would indicate the lack of information. Maybe they will fix it in WS2025. :)

For Exporter, the only suggestion would be a note in collector.diskdrive.md about the information Windows returns can be null.

Sixty502 avatar Sep 16 '24 04:09 Sixty502

Thermalzone has similiar issues. Win32_Sensor ist most of the time empty, too.

Feels like Microsoft create some generic solutions, but no hardware vendor implement them.

jkroepke avatar Sep 16 '24 06:09 jkroepke