Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kvch committed Aug 28, 2018
1 parent c175998 commit 8f916bd
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions libbeat/cmd/instance/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ func init() {
func setupMetrics(name string) error {
monitoring.NewFunc(beatMetrics, "memstats", reportMemStats, monitoring.Report)
monitoring.NewFunc(beatMetrics, "cpu", reportBeatCPU, monitoring.Report)
monitoring.NewFunc(beatMetrics, "fd", reportFDUsage, monitoring.Report)

monitoring.NewFunc(systemMetrics, "cpu", reportSystemCPUUsage, monitoring.Report)
if runtime.GOOS != "windows" {
monitoring.NewFunc(systemMetrics, "load", reportSystemLoadAverage, monitoring.Report)
}

setupPlatformSpecificMetrics()

beatProcessStats = &process.Stats{
Procs: []string{name},
Expand All @@ -61,6 +59,16 @@ func setupMetrics(name string) error {
return err
}

func setupPlatformSpecificMetrics() {
if runtime.GOOS != "windows" {
monitoring.NewFunc(systemMetrics, "load", reportSystemLoadAverage, monitoring.Report)
}

if runtime.GOOS == "linux" {
monitoring.NewFunc(beatMetrics, "fd", reportFDUsage, monitoring.Report)
}
}

func reportMemStats(m monitoring.Mode, V monitoring.Visitor) {
var stats runtime.MemStats
runtime.ReadMemStats(&stats)
Expand Down Expand Up @@ -226,8 +234,6 @@ func reportFDUsage(_ monitoring.Mode, V monitoring.Visitor) {
func getFDUsage() (open, hardLimit, softLimit uint64, err error) {
state, err := getBeatProcessState()
if err != nil {
// TODO copy
logp.Err("baj van")
return 0, 0, 0, err
}

Expand Down

0 comments on commit 8f916bd

Please sign in to comment.