Skip to content

Commit e008024

Browse files
Refactor of system/memory metricset (#26334)
* init commit * start on linux implementation * finish linux, start work on darwin * fix build platform issues * fix metrics on darwin * add openbsd * add freebsd * add windows, aix * fix aix build * finish memory * fix up opt changes * cleanup metricset code * fix up folder methods * fix calculations, Opt API, gomod * make notice * go mod tidy, mage fmt * fix up linux/memory * update fields * update system tests * fix system tests, again * fix extra print statements * fix if block in fillPercentages * vix Value API * fix up tests, opt
1 parent 4accfa8 commit e008024

File tree

28 files changed

+1502
-637
lines changed

28 files changed

+1502
-637
lines changed

NOTICE.txt

Lines changed: 212 additions & 212 deletions
Large diffs are not rendered by default.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ require (
7474
github.com/elastic/go-sysinfo v1.7.0
7575
github.com/elastic/go-txfile v0.0.7
7676
github.com/elastic/go-ucfg v0.8.3
77-
github.com/elastic/go-windows v1.0.1 // indirect
77+
github.com/elastic/go-windows v1.0.1
7878
github.com/elastic/gosigar v0.14.1
7979
github.com/fatih/color v1.9.0
8080
github.com/fsnotify/fsevents v0.1.1

libbeat/metric/system/memory/memory.go

Lines changed: 0 additions & 172 deletions
This file was deleted.

libbeat/metric/system/memory/memory_test.go

Lines changed: 0 additions & 96 deletions
This file was deleted.

libbeat/metric/system/process/process.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
"github.com/elastic/beats/v7/libbeat/common"
3333
"github.com/elastic/beats/v7/libbeat/common/match"
3434
"github.com/elastic/beats/v7/libbeat/logp"
35-
"github.com/elastic/beats/v7/libbeat/metric/system/memory"
35+
sysinfo "github.com/elastic/go-sysinfo"
3636
sigar "github.com/elastic/gosigar"
3737
"github.com/elastic/gosigar/cgroup"
3838
)
@@ -288,12 +288,20 @@ func GetOwnResourceUsageTimeInMillis() (int64, int64, error) {
288288

289289
func (procStats *Stats) getProcessEvent(process *Process) common.MapStr {
290290

291+
// This is a holdover until we migrate this library to metricbeat/internal
292+
// At which point we'll use the memory code there.
291293
var totalPhyMem uint64
292-
baseMem, err := memory.Get()
294+
host, err := sysinfo.Host()
293295
if err != nil {
294-
procStats.logger.Warnf("Getting memory details: %v", err)
296+
procStats.logger.Warnf("Getting host details: %v", err)
295297
} else {
296-
totalPhyMem = baseMem.Mem.Total
298+
memStats, err := host.Memory()
299+
if err != nil {
300+
procStats.logger.Warnf("Getting memory details: %v", err)
301+
} else {
302+
totalPhyMem = memStats.Total
303+
}
304+
297305
}
298306

299307
proc := common.MapStr{

metricbeat/docs/fields.asciidoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51614,6 +51614,18 @@ format: bytes
5161451614
The total amount of free memory in bytes. This value does not include memory consumed by system caches and buffers (see system.memory.actual.free).
5161551615

5161651616

51617+
type: long
51618+
51619+
format: bytes
51620+
51621+
--
51622+
51623+
*`system.memory.cached`*::
51624+
+
51625+
--
51626+
Total Cached memory on system.
51627+
51628+
5161751629
type: long
5161851630

5161951631
format: bytes

0 commit comments

Comments
 (0)