aboutsummaryrefslogtreecommitdiff
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
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>
-rw-r--r--CHANGELOG.md2
-rw-r--r--collector/bonding_linux.go4
-rw-r--r--collector/fixtures/sys.ttar32
3 files changed, 36 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 77f84cb..6d6abb2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@
6 other network metrics #1224 6 other network metrics #1224
7* The cpufreq metrics now separate the `cpufreq` and `scaling` data based on what the driver provides. #1248 7* The cpufreq metrics now separate the `cpufreq` and `scaling` data based on what the driver provides. #1248
8* The labels for the network_up metric have changed, see issue #1236 8* The labels for the network_up metric have changed, see issue #1236
9* Bonding collector now uses `mii_status` instead of `operstatus` #1124
9 10
10### Changes 11### Changes
11 12
@@ -21,6 +22,7 @@
21* [FEATURE] Add kstat-based Solaris metrics for boottime, cpu and zfs collectors #1197 22* [FEATURE] Add kstat-based Solaris metrics for boottime, cpu and zfs collectors #1197
22* [FEATURE] Add uname collector for FreeBSD #1239 23* [FEATURE] Add uname collector for FreeBSD #1239
23* [FEATURE] Add diskstats collector for OpenBSD #1250 24* [FEATURE] Add diskstats collector for OpenBSD #1250
25* [CHANGE] Bonding state uses mii_status #1124
24 26
25## 0.17.0 / 2018-11-30 27## 0.17.0 / 2018-11-30
26 28
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
diff --git a/collector/fixtures/sys.ttar b/collector/fixtures/sys.ttar
index 27b0cb4..ee30c81 100644
--- a/collector/fixtures/sys.ttar
+++ b/collector/fixtures/sys.ttar
@@ -704,6 +704,14 @@ Mode: 644
704Directory: sys/class/net/dmz/slave_eth0 704Directory: sys/class/net/dmz/slave_eth0
705Mode: 755 705Mode: 755
706# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 706# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
707Directory: sys/class/net/dmz/slave_eth0/bonding_slave
708Mode: 755
709# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
710Path: sys/class/net/dmz/slave_eth0/bonding_slave/mii_status
711Lines: 1
712up
713Mode: 644
714# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
707Path: sys/class/net/dmz/slave_eth0/operstate 715Path: sys/class/net/dmz/slave_eth0/operstate
708Lines: 1 716Lines: 1
709up 717up
@@ -712,6 +720,14 @@ Mode: 644
712Directory: sys/class/net/dmz/slave_eth4 720Directory: sys/class/net/dmz/slave_eth4
713Mode: 755 721Mode: 755
714# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 722# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
723Directory: sys/class/net/dmz/slave_eth4/bonding_slave
724Mode: 755
725# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
726Path: sys/class/net/dmz/slave_eth4/bonding_slave/mii_status
727Lines: 1
728up
729Mode: 644
730# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
715Path: sys/class/net/dmz/slave_eth4/operstate 731Path: sys/class/net/dmz/slave_eth4/operstate
716Lines: 1 732Lines: 1
717up 733up
@@ -860,6 +876,14 @@ Mode: 644
860Directory: sys/class/net/int/slave_eth1 876Directory: sys/class/net/int/slave_eth1
861Mode: 755 877Mode: 755
862# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 878# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
879Directory: sys/class/net/int/slave_eth1/bonding_slave
880Mode: 755
881# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
882Path: sys/class/net/int/slave_eth1/bonding_slave/mii_status
883Lines: 1
884down
885Mode: 644
886# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
863Path: sys/class/net/int/slave_eth1/operstate 887Path: sys/class/net/int/slave_eth1/operstate
864Lines: 1 888Lines: 1
865down 889down
@@ -868,6 +892,14 @@ Mode: 644
868Directory: sys/class/net/int/slave_eth5 892Directory: sys/class/net/int/slave_eth5
869Mode: 755 893Mode: 755
870# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 894# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
895Directory: sys/class/net/int/slave_eth5/bonding_slave
896Mode: 755
897# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
898Path: sys/class/net/int/slave_eth5/bonding_slave/mii_status
899Lines: 1
900up
901Mode: 644
902# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
871Path: sys/class/net/int/slave_eth5/operstate 903Path: sys/class/net/int/slave_eth5/operstate
872Lines: 1 904Lines: 1
873up 905up