Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PdhExpandWildCardPathW will not expand counter paths in 32 bit windows systems #12622

Merged
merged 4 commits into from
Jun 28, 2019

Conversation

narph
Copy link
Contributor

@narph narph commented Jun 20, 2019

PdhExpandWildCardPathW will not expand wildcard counter paths in 32 bit windows systems and will not return any exceptions.
The path list will only contain the initial counter query will pass the following validation rules in reader.go.
A workaround has been built using PdhExpandCounterPathW function instead which seems to return the list of counter paths and extra validation has been added.
Will still keep using PdhExpandWildCardPathW for 62 bit systems as this function supersedes PdhExpandCounterPathW.
Also, fixed the perfmon tests failing on the 32 bit systems.

Should fix #12590

…y exceptions in 32 bit windows systems. Awrokaround was built using PdhExpandCounterPathW function instead.
@narph narph requested a review from a team as a code owner June 20, 2019 12:33
@narph narph changed the title PdhExpandCounterPathW will not expand counter paths in 32 bit windows systems PdhExpandWildCardPathW will not expand counter paths in 32 bit windows systems Jun 20, 2019
@narph narph self-assigned this Jun 20, 2019
@narph narph added Team:Integrations Label for the Integrations team :Windows Metricbeat Metricbeat [zube]: In Progress labels Jun 20, 2019
@@ -74,9 +75,10 @@ func NewReader(config Config) (*Reader, error) {
return nil, errors.Wrapf(err, `failed to expand counter (query="%v")`, counter.Query)
}
}
if childQueries == nil || len(childQueries) == 0 {
// check if the pdhexpandcounterpath/pdhexpandwildcardpath functions have expanded the counter successfully.
if childQueries == nil || len(childQueries) == 0 || (len(childQueries) == 1 && strings.Contains(childQueries[0], "*")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not possible that a wildcard expands to a single path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsoriano , yes that should be possible but the path should not still contain the wildcard "*", this is why the condition (len(childQueries) == 1 && strings.Contains(childQueries[0], "*"). Am I missing something here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok, sorry, I misunderstood, all good.

metricbeat/module/windows/perfmon/reader.go Outdated Show resolved Hide resolved
Co-Authored-By: Jaime Soriano Pastor <jaime.soriano@elastic.co>
query.Close()
return nil, errors.Wrapf(err, `failed to expand counter (query="%v")`, counter.Query)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch here btw 🙂 I guess it was failing silently before? (errors.Wrap(nil) returns nil)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsoriano , yes, found it while running the tests.

@narph
Copy link
Contributor Author

narph commented Jun 26, 2019

jenkins, test this

1 similar comment
@narph
Copy link
Contributor Author

narph commented Jun 27, 2019

jenkins, test this

@narph narph merged commit d9b31f2 into elastic:master Jun 28, 2019
@narph narph deleted the fix-perfmon-win32bit branch June 28, 2019 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Metricbeat Metricbeat Team:Integrations Label for the Integrations team :Windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Couldn't get the Perfmon data for all the processes in Windows-7 32 bit server
3 participants