feat: add count of bonded slaves (for easier alerting) (#9762)
This commit is contained in:
parent
779ed5ec42
commit
0e9391d43f
|
|
@ -27,6 +27,7 @@ The plugin collects these metrics from `/proc/net/bonding/*` files.
|
||||||
- bond_slave
|
- bond_slave
|
||||||
- failures
|
- failures
|
||||||
- status
|
- status
|
||||||
|
- count
|
||||||
|
|
||||||
### Description:
|
### Description:
|
||||||
|
|
||||||
|
|
@ -39,6 +40,9 @@ status
|
||||||
|
|
||||||
failures
|
failures
|
||||||
Amount of failures for bond's slave interface.
|
Amount of failures for bond's slave interface.
|
||||||
|
|
||||||
|
count
|
||||||
|
Number of slaves attached to bond
|
||||||
```
|
```
|
||||||
|
|
||||||
### Tags:
|
### Tags:
|
||||||
|
|
@ -79,7 +83,9 @@ Output:
|
||||||
> bond,bond=bond1,host=local active_slave="eth0",status=1i 1509704525000000000
|
> bond,bond=bond1,host=local active_slave="eth0",status=1i 1509704525000000000
|
||||||
> bond_slave,bond=bond1,interface=eth0,host=local status=1i,failures=0i 1509704525000000000
|
> bond_slave,bond=bond1,interface=eth0,host=local status=1i,failures=0i 1509704525000000000
|
||||||
> bond_slave,host=local,bond=bond1,interface=eth1 status=1i,failures=0i 1509704525000000000
|
> bond_slave,host=local,bond=bond1,interface=eth1 status=1i,failures=0i 1509704525000000000
|
||||||
|
> bond_slave,host=local,bond=bond1 count=2i 1509704525000000000
|
||||||
> bond,bond=bond0,host=isvetlov-mac.local status=1i 1509704525000000000
|
> bond,bond=bond0,host=isvetlov-mac.local status=1i 1509704525000000000
|
||||||
> bond_slave,bond=bond0,interface=eth1,host=local status=1i,failures=0i 1509704525000000000
|
> bond_slave,bond=bond0,interface=eth1,host=local status=1i,failures=0i 1509704525000000000
|
||||||
> bond_slave,bond=bond0,interface=eth2,host=local status=1i,failures=0i 1509704525000000000
|
> bond_slave,bond=bond0,interface=eth2,host=local status=1i,failures=0i 1509704525000000000
|
||||||
|
> bond_slave,bond=bond0,host=local count=2i 1509704525000000000
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,7 @@ func (bond *Bond) gatherBondPart(bondName string, rawFile string, acc telegraf.A
|
||||||
func (bond *Bond) gatherSlavePart(bondName string, rawFile string, acc telegraf.Accumulator) error {
|
func (bond *Bond) gatherSlavePart(bondName string, rawFile string, acc telegraf.Accumulator) error {
|
||||||
var slave string
|
var slave string
|
||||||
var status int
|
var status int
|
||||||
|
var slaveCount int
|
||||||
|
|
||||||
scanner := bufio.NewScanner(strings.NewReader(rawFile))
|
scanner := bufio.NewScanner(strings.NewReader(rawFile))
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
|
|
@ -155,8 +156,16 @@ func (bond *Bond) gatherSlavePart(bondName string, rawFile string, acc telegraf.
|
||||||
"interface": slave,
|
"interface": slave,
|
||||||
}
|
}
|
||||||
acc.AddFields("bond_slave", fields, tags)
|
acc.AddFields("bond_slave", fields, tags)
|
||||||
|
slaveCount++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fields := map[string]interface{}{
|
||||||
|
"count": slaveCount,
|
||||||
|
}
|
||||||
|
tags := map[string]string{
|
||||||
|
"bond": bondName,
|
||||||
|
}
|
||||||
|
acc.AddFields("bond_slave", fields, tags)
|
||||||
|
|
||||||
return scanner.Err()
|
return scanner.Err()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,4 +75,5 @@ func TestGatherBondInterface(t *testing.T) {
|
||||||
acc.AssertContainsTaggedFields(t, "bond", map[string]interface{}{"active_slave": "eth2", "status": 1}, map[string]string{"bond": "bondAB"})
|
acc.AssertContainsTaggedFields(t, "bond", map[string]interface{}{"active_slave": "eth2", "status": 1}, map[string]string{"bond": "bondAB"})
|
||||||
acc.AssertContainsTaggedFields(t, "bond_slave", map[string]interface{}{"failures": 2, "status": 0}, map[string]string{"bond": "bondAB", "interface": "eth3"})
|
acc.AssertContainsTaggedFields(t, "bond_slave", map[string]interface{}{"failures": 2, "status": 0}, map[string]string{"bond": "bondAB", "interface": "eth3"})
|
||||||
acc.AssertContainsTaggedFields(t, "bond_slave", map[string]interface{}{"failures": 0, "status": 1}, map[string]string{"bond": "bondAB", "interface": "eth2"})
|
acc.AssertContainsTaggedFields(t, "bond_slave", map[string]interface{}{"failures": 0, "status": 1}, map[string]string{"bond": "bondAB", "interface": "eth2"})
|
||||||
|
acc.AssertContainsTaggedFields(t, "bond_slave", map[string]interface{}{"count": 2}, map[string]string{"bond": "bondAB"})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue