aboutsummaryrefslogtreecommitdiff
path: root/collector/bonding_linux.go
diff options
context:
space:
mode:
authorSachi King <nakato@nakato.io>2019-02-10 21:00:04 +1100
committerBen Kochie <superq@gmail.com>2019-02-10 11:00:04 +0100
commit18fc512fc4d50c2463fa4de8845d33c04a0ed529 (patch)
treef67aa27f91e5313289545728dbaff57e1ca2e0d0 /collector/bonding_linux.go
parente0d6d1185988bb1eb33779539399dd0e6cab0238 (diff)
downloadprometheus_node_collector-18fc512fc4d50c2463fa4de8845d33c04a0ed529.tar.bz2
prometheus_node_collector-18fc512fc4d50c2463fa4de8845d33c04a0ed529.tar.xz
prometheus_node_collector-18fc512fc4d50c2463fa4de8845d33c04a0ed529.zip
Bond: Monitor bond mii_status not link operstate (#1124)
With a bond interface the state of the slave interface from the bond's point of view is reflected in `mii_status` and is independent of the link's `operstate`. When a bond is monitored with `miimon`, `mii_status` will reflect the state of the physical link as configured via the operator. When a bond is monitored via `arp_interval` the `mii_status` will reflect the results of the bond ARP checking. This means the link can be down from the bond's point of view, but up from a physical connection point of view. If a bond is not monitored via miimon or arp, the `mii_status` should likely be always `up`, however I have observed a case where this is not true and the `operstate` is `up` while `mii_status` is `down`. Kernel bond documentation stresses that a bond should not be configured without one of `mii_mon` or `arp_interval` configured however. This change results in the metric 'node_bonding_active' matching the up/down state of the bond's point of view rather than operstate. Signed-off-by: Sachi King <nakato@nakato.io>
Diffstat (limited to 'collector/bonding_linux.go')
-rw-r--r--collector/bonding_linux.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/collector/bonding_linux.go b/collector/bonding_linux.go
index 829ab6d..f67e2a3 100644
--- a/collector/bonding_linux.go
+++ b/collector/bonding_linux.go
@@ -82,10 +82,10 @@ func readBondingStats(root string) (status map[string][2]int, err error) {
82 } 82 }
83 sstat := [2]int{0, 0} 83 sstat := [2]int{0, 0}
84 for _, slave := range strings.Fields(string(slaves)) { 84 for _, slave := range strings.Fields(string(slaves)) {
85 state, err := ioutil.ReadFile(filepath.Join(root, master, fmt.Sprintf("lower_%s", slave), "operstate")) 85 state, err := ioutil.ReadFile(filepath.Join(root, master, fmt.Sprintf("lower_%s", slave), "bonding_slave", "mii_status"))
86 if os.IsNotExist(err) { 86 if os.IsNotExist(err) {
87 // some older? kernels use slave_ prefix 87 // some older? kernels use slave_ prefix
88 state, err = ioutil.ReadFile(filepath.Join(root, master, fmt.Sprintf("slave_%s", slave), "operstate")) 88 state, err = ioutil.ReadFile(filepath.Join(root, master, fmt.Sprintf("slave_%s", slave), "bonding_slave", "mii_status"))
89 } 89 }
90 if err != nil { 90 if err != nil {
91 return nil, err 91 return nil, err