private NetworkMetrics GetNetworkMetrics() { var result = new NetworkMetrics(); var properties = TcpExtensions.GetIPGlobalPropertiesSafely(); var ipv4Stats = properties.GetTcpIPv4StatisticsSafely(); var ipv6Stats = properties.GetTcpIPv6StatisticsSafely(); var currentIpv4Connections = ipv4Stats.GetCurrentConnectionsSafely() ?? 0; var currentIpv6Connections = ipv6Stats.GetCurrentConnectionsSafely() ?? 0; result.TcpActiveConnections = currentIpv4Connections + currentIpv6Connections; result.ConcurrentRequestsCount = Server.Metrics.Requests.ConcurrentRequestsCount; result.TotalRequests = Server.Metrics.Requests.RequestsPerSec.Count; result.RequestsPerSec = Server.Metrics.Requests.RequestsPerSec.OneMinuteRate; result.LastRequestTimeInSec = Server.Statistics.LastRequestTime.HasValue ? (SystemTime.UtcNow - Server.Statistics.LastRequestTime.Value).TotalSeconds : (double?)null; result.LastAuthorizedNonClusterAdminRequestTimeInSec = Server.Statistics.LastAuthorizedNonClusterAdminRequestTime.HasValue ? (SystemTime.UtcNow - Server.Statistics.LastAuthorizedNonClusterAdminRequestTime.Value).TotalSeconds : (double?)null; return(result); }
protected override Gauge32 GetData() { var properties = TcpExtensions.GetIPGlobalPropertiesSafely(); var ipv4Stats = properties.GetTcpIPv4StatisticsSafely(); var ipv6Stats = properties.GetTcpIPv6StatisticsSafely(); var currentIpv4Connections = ipv4Stats.GetCurrentConnectionsSafely() ?? 0; var currentIpv6Connections = ipv6Stats.GetCurrentConnectionsSafely() ?? 0; return(new Gauge32(currentIpv4Connections + currentIpv6Connections)); }
public static TcpConnections GetConnections() { var properties = TcpExtensions.GetIPGlobalPropertiesSafely(); var ipv4Stats = properties.GetTcpIPv4StatisticsSafely(); var ipv6Stats = properties.GetTcpIPv6StatisticsSafely(); var currentIpv4Connections = ipv4Stats.GetCurrentConnectionsSafely() ?? 0; var currentIpv6Connections = ipv6Stats.GetCurrentConnectionsSafely() ?? 0; return(new TcpConnections { CurrentIpv4 = currentIpv4Connections, CurrentIpv6 = currentIpv6Connections }); }
public async Task Statistics() { var properties = TcpExtensions.GetIPGlobalPropertiesSafely(); var ipv4Stats = properties.GetTcpIPv4StatisticsSafely(); var ipv6Stats = properties.GetTcpIPv6StatisticsSafely(); var djv = new DynamicJsonValue { ["IPv4"] = ToDynamic(ipv4Stats), ["IPv6"] = ToDynamic(ipv6Stats) }; using (ServerStore.ContextPool.AllocateOperationContext(out JsonOperationContext context)) await using (var writer = new AsyncBlittableJsonTextWriter(context, ResponseBodyStream())) { context.Write(writer, djv); }