mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-12-28 23:19:46 -08:00
netclass: retrieve interface names and filter before parsing
We should filter excluded interfaces before parsing the interface details. This change is based on https://github.com/prometheus/procfs/pull/376 Signed-off-by: Jan Fajerski <jfajersk@redhat.com>
This commit is contained in:
parent
90d469805a
commit
e656b79297
|
@ -183,15 +183,21 @@ func pushMetric(ch chan<- prometheus.Metric, subsystem string, name string, valu
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *netClassCollector) getNetClassInfo() (sysfs.NetClass, error) {
|
func (c *netClassCollector) getNetClassInfo() (sysfs.NetClass, error) {
|
||||||
netClass, err := c.fs.NetClass()
|
netClass := sysfs.NetClass{}
|
||||||
|
netDevices, err := c.fs.NetClassDevices()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return netClass, err
|
return netClass, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for device := range netClass {
|
for _, device := range netDevices {
|
||||||
if c.ignoredDevicesPattern.MatchString(device) {
|
if c.ignoredDevicesPattern.MatchString(device) {
|
||||||
delete(netClass, device)
|
continue
|
||||||
}
|
}
|
||||||
|
interfaceClass, err := c.fs.NetClassByIface(device)
|
||||||
|
if err != nil {
|
||||||
|
return netClass, err
|
||||||
|
}
|
||||||
|
netClass[device] = *interfaceClass
|
||||||
}
|
}
|
||||||
|
|
||||||
return netClass, nil
|
return netClass, nil
|
||||||
|
|
Loading…
Reference in a new issue