From e107e4257545333d189e3c64f0e973da7e896511 Mon Sep 17 00:00:00 2001 From: Josh Powers Date: Tue, 14 Mar 2023 08:18:35 -0600 Subject: [PATCH 1/3] fix(inputs.ethtool): check for nil fixes: #12866 --- plugins/inputs/ethtool/namespace_linux.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/inputs/ethtool/namespace_linux.go b/plugins/inputs/ethtool/namespace_linux.go index a3d7d9e1577b8..68df8ff6977dc 100644 --- a/plugins/inputs/ethtool/namespace_linux.go +++ b/plugins/inputs/ethtool/namespace_linux.go @@ -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 From 736f028c03806a8263361f0b0067d4a636c5624a Mon Sep 17 00:00:00 2001 From: Josh Powers Date: Tue, 14 Mar 2023 13:27:19 -0600 Subject: [PATCH 2/3] ignore operation not supported error --- plugins/inputs/ethtool/ethtool_linux.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/inputs/ethtool/ethtool_linux.go b/plugins/inputs/ethtool/ethtool_linux.go index 7fcd4cc213533..ec2ba5ca7a552 100644 --- a/plugins/inputs/ethtool/ethtool_linux.go +++ b/plugins/inputs/ethtool/ethtool_linux.go @@ -133,11 +133,10 @@ func (e *Ethtool) gatherEthtoolStats(iface NamespacedInterface, acc telegraf.Acc } cmdget, err := e.command.Get(iface) - if err != nil { + 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 } From f86b29304c8cb379cfa751bf8f8bc98726a993fb Mon Sep 17 00:00:00 2001 From: Josh Powers Date: Tue, 21 Mar 2023 10:20:33 -0600 Subject: [PATCH 3/3] document error string --- plugins/inputs/ethtool/ethtool_linux.go | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/inputs/ethtool/ethtool_linux.go b/plugins/inputs/ethtool/ethtool_linux.go index ec2ba5ca7a552..009038f6cb6d5 100644 --- a/plugins/inputs/ethtool/ethtool_linux.go +++ b/plugins/inputs/ethtool/ethtool_linux.go @@ -133,6 +133,7 @@ func (e *Ethtool) gatherEthtoolStats(iface NamespacedInterface, acc telegraf.Acc } cmdget, err := e.command.Get(iface) + // 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