-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
data.go
43 lines (36 loc) · 886 Bytes
/
data.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
36
37
38
39
40
41
42
43
package cluster_disk
import (
"encoding/json"
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/logp"
)
type StatsCluster struct {
TotalUsedBytes int64 `json:"total_used_bytes"`
TotalBytes int64 `json:"total_bytes"`
TotalAvailBytes int64 `json:"total_avail_bytes"`
}
type Output struct {
StatsCluster StatsCluster `json:"stats"`
}
type DfRequest struct {
Status string `json:"status"`
Output Output `json:"output"`
}
func eventMapping(content []byte) common.MapStr {
var d DfRequest
err := json.Unmarshal(content, &d)
if err != nil {
logp.Err("Error: ", err)
}
return common.MapStr{
"used": common.MapStr{
"bytes": d.Output.StatsCluster.TotalUsedBytes,
},
"total": common.MapStr{
"bytes": d.Output.StatsCluster.TotalBytes,
},
"available": common.MapStr{
"bytes": d.Output.StatsCluster.TotalAvailBytes,
},
}
}