Browse Source

Handle nonexisting bonding_masters file (#569)

* silently ignore nonexisting bonding_masters file

Add an empty fixtures dir without a bonding_masters file to test.

* Moved the check to the Update() method

Dropped the empty test dir.
pull/572/head
Kai S 8 years ago committed by Tobias Schmidt
parent
commit
59f9b8c5c1
  1. 8
      collector/bonding_linux.go

8
collector/bonding_linux.go

@ -23,6 +23,7 @@ import (
"strings"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/log"
)
type bondingCollector struct {
@ -52,8 +53,13 @@ func NewBondingCollector() (Collector, error) {
// Update reads and exposes bonding states, implements Collector interface. Caution: This works only on linux.
func (c *bondingCollector) Update(ch chan<- prometheus.Metric) error {
bondingStats, err := readBondingStats(sysFilePath("class/net"))
statusfile := sysFilePath("class/net")
bondingStats, err := readBondingStats(statusfile)
if err != nil {
if os.IsNotExist(err) {
log.Debugf("Not collecting bonding, file does not exist: %s", statusfile)
return nil
}
return err
}
for master, status := range bondingStats {

Loading…
Cancel
Save