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

Fix diskio and memory bugs under windows #21992

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion metricbeat/module/system/diskio/diskio.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package diskio

import (
"fmt"
"runtime"

"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/beats/v7/libbeat/metric/system/diskio"
Expand Down Expand Up @@ -114,7 +115,7 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) error {
diskWriteBytes += counters.WriteBytes

//Add linux-only data if agent is off as not to make breaking changes.
if !m.IsAgent {
if !m.IsAgent && runtime.GOOS == "linux" {
result, err := m.statistics.CalcIOStatistics(counters)
if err != nil {
return errors.Wrap(err, "error calculating iostat")
Expand Down
6 changes: 3 additions & 3 deletions metricbeat/module/system/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func init() {
// MetricSet for fetching system memory metrics.
type MetricSet struct {
mb.BaseMetricSet
IsFleet bool
IsAgent bool
}

// New is a mb.MetricSetFactory that returns a memory.MetricSet.
Expand All @@ -53,7 +53,7 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
return nil, fmt.Errorf("unexpected module type")
}

return &MetricSet{BaseMetricSet: base, IsFleet: systemModule.IsAgent}, nil
return &MetricSet{BaseMetricSet: base, IsAgent: systemModule.IsAgent}, nil
}

// Fetch fetches memory metrics from the OS.
Expand Down Expand Up @@ -117,7 +117,7 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) error {
}

// for backwards compatibility, only report if we're not in fleet mode
if !m.IsFleet {
if !m.IsAgent {
err := linux.FetchLinuxMemStats(memory)
if err != nil {
return errors.Wrap(err, "error getting page stats")
Expand Down
4 changes: 3 additions & 1 deletion metricbeat/module/system/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,12 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) error {
// There's some more Windows memory quirks we need to deal with.
// "rss" is a linux concept, but "wss" is a direct match on Windows.
// "share" is also unavailable on Windows.
if runtime.GOOS == "windows" {
proc.Delete("memory.share")
}

if m.IsAgent {
if runtime.GOOS == "windows" {
proc.Delete("memory.share")
if setSize := getAndRemove(proc, "memory.rss"); setSize != nil {
proc.Put("memory.wss", setSize)
}
Expand Down