Skip to content

Commit

Permalink
Refactor of system/memory metricset (#26334)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
fearful-symmetry authored Jun 29, 2021
1 parent 4accfa8 commit e008024
Show file tree
Hide file tree
Showing 28 changed files with 1,502 additions and 637 deletions.
424 changes: 212 additions & 212 deletions NOTICE.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ require (
github.com/elastic/go-sysinfo v1.7.0
github.com/elastic/go-txfile v0.0.7
github.com/elastic/go-ucfg v0.8.3
github.com/elastic/go-windows v1.0.1 // indirect
github.com/elastic/go-windows v1.0.1
github.com/elastic/gosigar v0.14.1
github.com/fatih/color v1.9.0
github.com/fsnotify/fsevents v0.1.1
Expand Down
172 changes: 0 additions & 172 deletions libbeat/metric/system/memory/memory.go

This file was deleted.

96 changes: 0 additions & 96 deletions libbeat/metric/system/memory/memory_test.go

This file was deleted.

16 changes: 12 additions & 4 deletions libbeat/metric/system/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/beats/v7/libbeat/common/match"
"github.com/elastic/beats/v7/libbeat/logp"
"github.com/elastic/beats/v7/libbeat/metric/system/memory"
sysinfo "github.com/elastic/go-sysinfo"
sigar "github.com/elastic/gosigar"
"github.com/elastic/gosigar/cgroup"
)
Expand Down Expand Up @@ -288,12 +288,20 @@ func GetOwnResourceUsageTimeInMillis() (int64, int64, error) {

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

// This is a holdover until we migrate this library to metricbeat/internal
// At which point we'll use the memory code there.
var totalPhyMem uint64
baseMem, err := memory.Get()
host, err := sysinfo.Host()
if err != nil {
procStats.logger.Warnf("Getting memory details: %v", err)
procStats.logger.Warnf("Getting host details: %v", err)
} else {
totalPhyMem = baseMem.Mem.Total
memStats, err := host.Memory()
if err != nil {
procStats.logger.Warnf("Getting memory details: %v", err)
} else {
totalPhyMem = memStats.Total
}

}

proc := common.MapStr{
Expand Down
12 changes: 12 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -51614,6 +51614,18 @@ format: bytes
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).


type: long

format: bytes

--

*`system.memory.cached`*::
+
--
Total Cached memory on system.


type: long

format: bytes
Expand Down
Loading

0 comments on commit e008024

Please sign in to comment.