diff --git a/Vostok.Metrics.System/Host/NetworkUtilizationCollector_Linux.cs b/Vostok.Metrics.System/Host/NetworkUtilizationCollector_Linux.cs index d0a2ef5..9112752 100644 --- a/Vostok.Metrics.System/Host/NetworkUtilizationCollector_Linux.cs +++ b/Vostok.Metrics.System/Host/NetworkUtilizationCollector_Linux.cs @@ -145,7 +145,7 @@ NetworkUsage CreateNetworkUsage(string interfaceName, long receivedBytes, long s } // NOTE: See https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-net for details. - // NOTE: This value equals -1 if interface is disabled, so we will filter this values out later. + // NOTE: This value equals -1 if interface is disabled on older kernels, so we will filter this values out later. foreach (var networkUsage in networkInterfacesUsage.Values) { if (TryReadSpeed(networkUsage.InterfaceName, out var result) && int.TryParse(result, out var speed)) @@ -235,6 +235,12 @@ private static bool TryReadSpeed(string interfaceName, out string result) result = File.ReadAllText(path); return true; } + // NOTE: Disabled interfaces give this error on newer kernels. + catch (IOException ioError) when (ioError.Message.StartsWith("Invalid argument")) + { + result = null; + return false; + } catch (Exception error) { // NOTE: We expect teaming interface to not be able to read speed directly.