|
|
|
|
@@ -7,7 +7,9 @@ using LightlessSyncShared.Services;
|
|
|
|
|
using LightlessSyncShared.Utils.Configuration;
|
|
|
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using StackExchange.Redis;
|
|
|
|
|
using StackExchange.Redis.Extensions.Core.Abstractions;
|
|
|
|
|
using static LightlessSyncServer.Hubs.LightlessHub;
|
|
|
|
|
|
|
|
|
|
namespace LightlessSyncServer.Services;
|
|
|
|
|
|
|
|
|
|
@@ -52,6 +54,13 @@ public sealed class SystemInfoService : BackgroundService
|
|
|
|
|
_lightlessMetrics.SetGaugeTo(MetricsAPI.GaugeAvailableIOWorkerThreads, ioThreads);
|
|
|
|
|
|
|
|
|
|
var onlineUsers = (_redis.SearchKeysAsync("UID:*").GetAwaiter().GetResult()).Count();
|
|
|
|
|
|
|
|
|
|
var allLightfinderKeys = _redis.SearchKeysAsync("broadcast:*").GetAwaiter().GetResult().Where(c => !c.Contains("owner", StringComparison.Ordinal)).ToHashSet(StringComparer.Ordinal);
|
|
|
|
|
var allLightfinderItems = _redis.GetAllAsync<BroadcastRedisEntry>(allLightfinderKeys).GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
|
|
var countLightFinderUsers = allLightfinderItems.Count;
|
|
|
|
|
var countLightFinderSyncshells = allLightfinderItems.Count(static l => !string.IsNullOrEmpty(l.Value.GID));
|
|
|
|
|
|
|
|
|
|
SystemInfoDto = new SystemInfoDto()
|
|
|
|
|
{
|
|
|
|
|
OnlineUsers = onlineUsers,
|
|
|
|
|
@@ -66,10 +75,12 @@ public sealed class SystemInfoService : BackgroundService
|
|
|
|
|
using var db = await _dbContextFactory.CreateDbContextAsync(ct).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
_lightlessMetrics.SetGaugeTo(MetricsAPI.GaugeAuthorizedConnections, onlineUsers);
|
|
|
|
|
_lightlessMetrics.SetGaugeTo(MetricsAPI.GaugeLightFinderConnections, countLightFinderUsers);
|
|
|
|
|
_lightlessMetrics.SetGaugeTo(MetricsAPI.GaugePairs, db.ClientPairs.AsNoTracking().Count());
|
|
|
|
|
_lightlessMetrics.SetGaugeTo(MetricsAPI.GaugePairsPaused, db.Permissions.AsNoTracking().Where(p => p.IsPaused).Count());
|
|
|
|
|
_lightlessMetrics.SetGaugeTo(MetricsAPI.GaugePairsPaused, db.Permissions.AsNoTracking().Count(p => p.IsPaused));
|
|
|
|
|
_lightlessMetrics.SetGaugeTo(MetricsAPI.GaugeGroups, db.Groups.AsNoTracking().Count());
|
|
|
|
|
_lightlessMetrics.SetGaugeTo(MetricsAPI.GaugeGroupPairs, db.GroupPairs.AsNoTracking().Count());
|
|
|
|
|
_lightlessMetrics.SetGaugeTo(MetricsAPI.GaugeLightFinderGroups, countLightFinderSyncshells);
|
|
|
|
|
_lightlessMetrics.SetGaugeTo(MetricsAPI.GaugeUsersRegistered, db.Users.AsNoTracking().Count());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|