forked from DataDog/datadog-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resources.go
35 lines (28 loc) · 884 Bytes
/
resources.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-2019 Datadog, Inc.
// +build linux windows darwin
package resources
import (
"github.com/ninnemana/datadog-agent/pkg/util/log"
"github.com/DataDog/gohai/processes"
)
// GetPayload builds a payload of processes metadata collected from gohai.
func GetPayload(hostname string) *Payload {
// Get processes metadata from gohai
proc, err := new(processes.Processes).Collect()
if err != nil {
log.Warn("Failed to retrieve processes metadata: ", err)
return nil
}
processesPayload := map[string]interface{}{
"snaps": []interface{}{proc},
}
return &Payload{
Processes: processesPayload,
Meta: map[string]string{
"host": hostname,
},
}
}