Look for slave_ and lower_ prefixed device in proc

Looks like on newer kernels this is prefixed lower_ not slave_.
This commit is contained in:
Johannes 'fish' Ziemke 2014-10-03 13:16:37 +02:00
parent 0bf0f67503
commit 9f6fc576df
1 changed files with 6 additions and 1 deletions

View File

@ -5,6 +5,7 @@ package collector
import ( import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os"
"path" "path"
"strings" "strings"
@ -78,7 +79,11 @@ func readBondingStats(root string) (status map[string][2]int, err error) {
} }
sstat := [2]int{0, 0} sstat := [2]int{0, 0}
for _, slave := range strings.Fields(string(slaves)) { for _, slave := range strings.Fields(string(slaves)) {
state, err := ioutil.ReadFile(path.Join(root, master, fmt.Sprintf("slave_%s", slave), "operstate")) state, err := ioutil.ReadFile(path.Join(root, master, fmt.Sprintf("lower_%s", slave), "operstate"))
if os.IsNotExist(err) {
// some older? kernels use slave_ prefix
state, err = ioutil.ReadFile(path.Join(root, master, fmt.Sprintf("slave_%s", slave), "operstate"))
}
if err != nil { if err != nil {
return nil, err return nil, err
} }