DISKIO on Windows is not working

Hi Everyone,

I'm using metricbeats service on Windows, and during DISKIO task, it is constantly throwing error in ioCounter, when calling DeviceIoControl function in file(metricbeat/module/system/diskio/diskstat_windows_helper.go)

Error is "The parameter is invalid.". It is present from release 7.2 (the last one I tried to check if issue is there also) till current release

Actual problem is with diskPerformance structure. You are passing to DeviceIoControl, incorrect structure. WinAPI, is oriented to C/C++. structure. This means that it is waiting for aligned structure. In GoLang there is no such thing as structure alignment, therefore sizeof GoLang compared to C/C++ structure is not the same. Due to this, WinAPI call to DeviceIoControl is failing.
GoLang structure is missing 4 bytes of alignment.

I've added to the end of structure 4 bytes of alignment and DISKIO stopped failing, and was returning valid data. To the end of structure is needed as C/C++ will align this structure in the end, as memory will be divided in blocks of 8 bytes, and in raw case struct is 84 bytes, so it will have 10 blocks of 8 bytes and one not completely filled (4 bytes), which will be aligned with 4 bytes of padding. (Note: WinAPI structure members are ordered in correct manner to be memory efficient, this mean biggest element(8 byte LARGE_INTEGER) appears at the beginning, and other members order is to fit those blocks, that is why we got only last block aligned.)

It's critical issue, as basically one of important monitoring module is simply not working. Can you please fix this?

Hi @yaroslavmamrokha :slightly_smiling_face:

Thank you for track down this issue. My question is, why don't you contribute it to the GH repo directly?

Thanks again!

Hi Mario_Castro

As I see to add this fix, and create PR I need to sign contribution agreements. Or I can do this without it? And simply fork and create PR?
Also, I wanted to create bug on GH, so that it could be tracked. But in notes, as I see I need first to post it here, so it could be checked, and approved as bug, and then only to create bug in GH.

Thanks,
Yaroslav

I've opened new PR https://github.com/elastic/beats/pull/16553. But not sure if I'll be able to merge it.

Thanks,
Yaroslav

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.