diff options
Diffstat (limited to 'collector/bonding_linux.go')
-rw-r--r-- | collector/bonding_linux.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/collector/bonding_linux.go b/collector/bonding_linux.go index 78e94b2..863f62c 100644 --- a/collector/bonding_linux.go +++ b/collector/bonding_linux.go | |||
@@ -16,6 +16,7 @@ | |||
16 | package collector | 16 | package collector |
17 | 17 | ||
18 | import ( | 18 | import ( |
19 | "errors" | ||
19 | "fmt" | 20 | "fmt" |
20 | "io/ioutil" | 21 | "io/ioutil" |
21 | "os" | 22 | "os" |
@@ -59,7 +60,7 @@ func (c *bondingCollector) Update(ch chan<- prometheus.Metric) error { | |||
59 | statusfile := sysFilePath("class/net") | 60 | statusfile := sysFilePath("class/net") |
60 | bondingStats, err := readBondingStats(statusfile) | 61 | bondingStats, err := readBondingStats(statusfile) |
61 | if err != nil { | 62 | if err != nil { |
62 | if os.IsNotExist(err) { | 63 | if errors.Is(err, os.ErrNotExist) { |
63 | level.Debug(c.logger).Log("msg", "Not collecting bonding, file does not exist", "file", statusfile) | 64 | level.Debug(c.logger).Log("msg", "Not collecting bonding, file does not exist", "file", statusfile) |
64 | return ErrNoData | 65 | return ErrNoData |
65 | } | 66 | } |
@@ -86,7 +87,7 @@ func readBondingStats(root string) (status map[string][2]int, err error) { | |||
86 | sstat := [2]int{0, 0} | 87 | sstat := [2]int{0, 0} |
87 | for _, slave := range strings.Fields(string(slaves)) { | 88 | for _, slave := range strings.Fields(string(slaves)) { |
88 | state, err := ioutil.ReadFile(filepath.Join(root, master, fmt.Sprintf("lower_%s", slave), "bonding_slave", "mii_status")) | 89 | state, err := ioutil.ReadFile(filepath.Join(root, master, fmt.Sprintf("lower_%s", slave), "bonding_slave", "mii_status")) |
89 | if os.IsNotExist(err) { | 90 | if errors.Is(err, os.ErrNotExist) { |
90 | // some older? kernels use slave_ prefix | 91 | // some older? kernels use slave_ prefix |
91 | state, err = ioutil.ReadFile(filepath.Join(root, master, fmt.Sprintf("slave_%s", slave), "bonding_slave", "mii_status")) | 92 | state, err = ioutil.ReadFile(filepath.Join(root, master, fmt.Sprintf("slave_%s", slave), "bonding_slave", "mii_status")) |
92 | } | 93 | } |