forked from DataDog/datadog-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iostats.go
55 lines (44 loc) · 1.32 KB
/
iostats.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
49
50
51
52
53
54
55
// 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.
package system
import (
"regexp"
yaml "gopkg.in/yaml.v2"
"github.com/ninnemana/datadog-agent/pkg/autodiscovery/integration"
"github.com/ninnemana/datadog-agent/pkg/collector/check"
core "github.com/ninnemana/datadog-agent/pkg/collector/corechecks"
)
const (
// SectorSize is exported in github.com/shirou/gopsutil/disk (but not working!)
SectorSize = 512
kB = (1 << 10)
iostatsCheckName = "io"
)
// Configure the IOstats check
func (c *IOCheck) commonConfigure(data integration.Data, initConfig integration.Data) error {
if err := c.CommonConfigure(data); err != nil {
return err
}
conf := make(map[interface{}]interface{})
err := yaml.Unmarshal([]byte(initConfig), &conf)
if err != nil {
return err
}
blacklistRe, ok := conf["device_blacklist_re"]
if ok && blacklistRe != "" {
if regex, ok := blacklistRe.(string); ok {
c.blacklist, err = regexp.Compile(regex)
}
}
return err
}
func init() {
core.RegisterCheck(iostatsCheckName, ioFactory)
}
func ioFactory() check.Check {
return &IOCheck{
CheckBase: core.NewCheckBase(iostatsCheckName),
}
}