fix(inputs.ethtool): Check for nil (#12867)

This commit is contained in:
Joshua Powers 2023-03-22 06:03:44 -06:00 committed by GitHub
parent cd9e2c6194
commit 02eea01397
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -133,11 +133,11 @@ func (e *Ethtool) gatherEthtoolStats(iface NamespacedInterface, acc telegraf.Acc
}
cmdget, err := e.command.Get(iface)
if err != nil {
// error text is directly from running ethtool and syscalls
if err != nil && err.Error() != "operation not supported" {
acc.AddError(fmt.Errorf("%q get: %w", iface.Name, err))
return
}
for k, v := range cmdget {
fields[e.normalizeKey(k)] = v
}

View File

@ -96,7 +96,10 @@ func (n *NamespaceGoroutine) Get(intf NamespacedInterface) (map[string]uint64, e
}, nil
})
return result.(map[string]uint64), err
if result != nil {
return result.(map[string]uint64), err
}
return nil, err
}
// Start locks a goroutine to an OS thread and ties it to the namespace, then