Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tebaikin committed Nov 26, 2023
1 parent 118376d commit 0a8cd19
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions Vostok.Metrics.System/Host/TcpStateCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,26 @@ public void Collect(HostMetrics metrics)
var states = new Dictionary<TcpState, int>();

#if NET6_0_OR_GREATER
IterateOverTcpConnections(info =>

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
if (!states.ContainsKey(info.State))
states[info.State] = 0;
states[info.State]++;
});

IterateOverTcpConnections(info =>
{
if (!states.ContainsKey(info.State))
states[info.State] = 0;
states[info.State]++;
});
}
else
{
foreach (var tcpConnection in IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpConnections())
{
if (!states.ContainsKey(tcpConnection.State))
states[tcpConnection.State] = 0;
states[tcpConnection.State]++;
}
}

#else

foreach (var tcpConnection in IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpConnections())
Expand Down

0 comments on commit 0a8cd19

Please sign in to comment.