forked from rancher/agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
disk.go
48 lines (41 loc) · 1.26 KB
/
disk.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
44
45
46
47
48
package hostInfo
import (
"github.com/pkg/errors"
"github.com/rancher/agent/model"
"github.com/rancher/agent/utilities/constants"
)
type DiskCollector struct {
Unit uint64
InfoData model.InfoData
DockerStorageDriver string
}
func (d DiskCollector) GetData() (map[string]interface{}, error) {
infoData := d.InfoData
data := map[string]interface{}{
"fileSystems": map[string]interface{}{},
"mountPoints": map[string]interface{}{},
"dockerStorageDriverStatus": map[string]interface{}{},
"dockerStorageDriver": infoData.Info.Driver,
}
mfs, err := d.getMachineFilesystems(infoData)
if err != nil {
return data, errors.Wrap(err, constants.DiskGetDataError+"failed get filesystem info")
}
for key, value := range mfs {
data["fileSystems"].(map[string]interface{})[key] = value
}
mp, err := d.getMountPoints()
if err != nil {
return data, errors.Wrap(err, constants.DiskGetDataError+"failed get mountpoint info")
}
for key, value := range mp {
data["mountPoints"].(map[string]interface{})[key] = value
}
return data, nil
}
func (d DiskCollector) KeyName() string {
return "diskInfo"
}
func (d DiskCollector) GetLabels(prefix string) (map[string]string, error) {
return map[string]string{}, nil
}