Skip to content

Commit edc40d1

Browse files
authored
collector/ethtool: skip full scan of NetClass directories (#3239)
ethtool only uses the device names from `NetClassDevices()`, not the whole NetClass data from `NetClass()`. Improves ethtool collector performance on systems with lots of excluded devices. Signed-off-by: Will Jordan <[email protected]>
1 parent 2f21133 commit edc40d1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

collector/ethtool_linux.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ func (c *ethtoolCollector) updateSpeeds(ch chan<- prometheus.Metric, prefix stri
372372
}
373373

374374
func (c *ethtoolCollector) Update(ch chan<- prometheus.Metric) error {
375-
netClass, err := c.fs.NetClass()
375+
netClass, err := c.fs.NetClassDevices()
376376
if err != nil {
377377
if errors.Is(err, os.ErrNotExist) || errors.Is(err, os.ErrPermission) {
378378
c.logger.Debug("Could not read netclass file", "err", err)
@@ -385,7 +385,7 @@ func (c *ethtoolCollector) Update(ch chan<- prometheus.Metric) error {
385385
return fmt.Errorf("no network devices found")
386386
}
387387

388-
for device := range netClass {
388+
for _, device := range netClass {
389389
var stats map[string]uint64
390390
var err error
391391

0 commit comments

Comments
 (0)