prometheus-community / windows_exporter

Prometheus exporter for Windows machines
MIT License
2.92k stars 704 forks source link

diskdrive collector (windows_diskdrive_availability) #1607

Open Sixty502 opened 2 months ago

Sixty502 commented 2 months ago

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

DiniFarb commented 2 months ago

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

Sixty502 commented 2 months ago

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.

jkroepke commented 2 months ago

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

Sixty502 commented 1 month ago

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.

jkroepke commented 1 month ago

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.