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

Assume all swap memory is free on values overflow #9383

Merged
merged 4 commits into from
Dec 6, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha1...master[Check the HEAD d
- Fix autodiscover configurations stopping when metadata is missing. {pull}8851[8851]
- Log events at the debug level when dropped by encoding problems. {pull}9251[9251]
- Refresh host metadata in add_host_metadata. {pull}9359[9359]
- Handle cases of free swap being bigger than total swap by assuming no swap is being used. {issue}6271[6271] {pull}[]
Copy link
Contributor

Choose a reason for hiding this comment

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

You haven't written the pull number. Maybe I'd add the module involved too


*Auditbeat*

Expand Down
8 changes: 8 additions & 0 deletions libbeat/metric/system/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ func GetSwap() (*SwapStat, error) {
return nil, err
}

// This shouldn't happen, but it has been reported to happen and
// this can provoke too big values for used swap.
// Workaround this by assuming that all swap is free in that case.
if swap.Free > swap.Total || swap.Used > swap.Total {
jsoriano marked this conversation as resolved.
Show resolved Hide resolved
swap.Free = swap.Total
swap.Used = 0
}

return &SwapStat{Swap: swap}, nil
}

Expand Down