From 43b9c6f90ee72e21c54b878a3ec5692d0f3d9575 Mon Sep 17 00:00:00 2001 From: CakeAndBanana Date: Tue, 14 Oct 2025 18:45:57 +0200 Subject: [PATCH 1/4] Added lightfinder users in metrics --- .../LightlessSyncServer/Services/SystemInfoService.cs | 2 ++ LightlessSyncServer/LightlessSyncShared/Metrics/MetricsAPI.cs | 1 + 2 files changed, 3 insertions(+) diff --git a/LightlessSyncServer/LightlessSyncServer/Services/SystemInfoService.cs b/LightlessSyncServer/LightlessSyncServer/Services/SystemInfoService.cs index 449510a..3895920 100644 --- a/LightlessSyncServer/LightlessSyncServer/Services/SystemInfoService.cs +++ b/LightlessSyncServer/LightlessSyncServer/Services/SystemInfoService.cs @@ -52,6 +52,7 @@ public sealed class SystemInfoService : BackgroundService _lightlessMetrics.SetGaugeTo(MetricsAPI.GaugeAvailableIOWorkerThreads, ioThreads); var onlineUsers = (_redis.SearchKeysAsync("UID:*").GetAwaiter().GetResult()).Count(); + var lightfinderUsers = (_redis.SearchKeysAsync("broadcast:*").GetAwaiter().GetResult()).Count(); SystemInfoDto = new SystemInfoDto() { OnlineUsers = onlineUsers, @@ -66,6 +67,7 @@ public sealed class SystemInfoService : BackgroundService using var db = await _dbContextFactory.CreateDbContextAsync(ct).ConfigureAwait(false); _lightlessMetrics.SetGaugeTo(MetricsAPI.GaugeAuthorizedConnections, onlineUsers); + _lightlessMetrics.SetGaugeTo(MetricsAPI.GaugeLightfinderConnections, lightfinderUsers); _lightlessMetrics.SetGaugeTo(MetricsAPI.GaugePairs, db.ClientPairs.AsNoTracking().Count()); _lightlessMetrics.SetGaugeTo(MetricsAPI.GaugePairsPaused, db.Permissions.AsNoTracking().Where(p => p.IsPaused).Count()); _lightlessMetrics.SetGaugeTo(MetricsAPI.GaugeGroups, db.Groups.AsNoTracking().Count()); diff --git a/LightlessSyncServer/LightlessSyncShared/Metrics/MetricsAPI.cs b/LightlessSyncServer/LightlessSyncShared/Metrics/MetricsAPI.cs index f3b09a6..9139a55 100644 --- a/LightlessSyncServer/LightlessSyncShared/Metrics/MetricsAPI.cs +++ b/LightlessSyncServer/LightlessSyncShared/Metrics/MetricsAPI.cs @@ -9,6 +9,7 @@ public class MetricsAPI public const string GaugeAvailableIOWorkerThreads = "lightless_available_threadpool_io"; public const string GaugeUsersRegistered = "lightless_users_registered"; public const string CounterUsersRegisteredDeleted = "lightless_users_registered_deleted"; + public const string GaugeLightfinderConnections = "lightless_lightfinder_connections"; public const string GaugePairs = "lightless_pairs"; public const string GaugePairsPaused = "lightless_pairs_paused"; public const string GaugeFilesTotal = "lightless_files"; From f686f7a6da1a9c777f7a05c600609262cd374e7a Mon Sep 17 00:00:00 2001 From: CakeAndBanana Date: Wed, 15 Oct 2025 02:47:18 +0200 Subject: [PATCH 2/4] Added lightfinder metric on startup --- LightlessSyncServer/LightlessSyncServer/Startup.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/LightlessSyncServer/LightlessSyncServer/Startup.cs b/LightlessSyncServer/LightlessSyncServer/Startup.cs index b647e85..452ad4c 100644 --- a/LightlessSyncServer/LightlessSyncServer/Startup.cs +++ b/LightlessSyncServer/LightlessSyncServer/Startup.cs @@ -295,6 +295,7 @@ public class Startup }, new List { MetricsAPI.GaugeAuthorizedConnections, + MetricsAPI.GaugeLightfinderConnections, MetricsAPI.GaugeConnections, MetricsAPI.GaugePairs, MetricsAPI.GaugePairsPaused, From 6beda853f74949371c020d40eb5dc9dc1ad35805 Mon Sep 17 00:00:00 2001 From: CakeAndBanana Date: Wed, 15 Oct 2025 03:58:00 +0200 Subject: [PATCH 3/4] Added metric of broadcasted syncshells --- .../Services/SystemInfoService.cs | 15 ++++++++++++--- .../LightlessSyncServer/Startup.cs | 3 ++- .../LightlessSyncShared/Metrics/MetricsAPI.cs | 3 ++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/LightlessSyncServer/LightlessSyncServer/Services/SystemInfoService.cs b/LightlessSyncServer/LightlessSyncServer/Services/SystemInfoService.cs index 3895920..4dc39cf 100644 --- a/LightlessSyncServer/LightlessSyncServer/Services/SystemInfoService.cs +++ b/LightlessSyncServer/LightlessSyncServer/Services/SystemInfoService.cs @@ -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,7 +54,13 @@ public sealed class SystemInfoService : BackgroundService _lightlessMetrics.SetGaugeTo(MetricsAPI.GaugeAvailableIOWorkerThreads, ioThreads); var onlineUsers = (_redis.SearchKeysAsync("UID:*").GetAwaiter().GetResult()).Count(); - var lightfinderUsers = (_redis.SearchKeysAsync("broadcast:*").GetAwaiter().GetResult()).Count(); + + var allLightfinderKeys = _redis.SearchKeysAsync("broadcast:*").GetAwaiter().GetResult().Where(c => !c.Contains("owner", StringComparison.Ordinal)).ToHashSet(StringComparer.Ordinal); + var allLightfinderItems = _redis.GetAllAsync(allLightfinderKeys).GetAwaiter().GetResult(); + + var countLightFinderUsers = allLightfinderItems.Count; + var countLightFinderSyncshells = allLightfinderItems.Count(static l => string.IsNullOrEmpty(l.Value.GID)); + SystemInfoDto = new SystemInfoDto() { OnlineUsers = onlineUsers, @@ -67,11 +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, lightfinderUsers); + _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()); } diff --git a/LightlessSyncServer/LightlessSyncServer/Startup.cs b/LightlessSyncServer/LightlessSyncServer/Startup.cs index 452ad4c..3b9ba70 100644 --- a/LightlessSyncServer/LightlessSyncServer/Startup.cs +++ b/LightlessSyncServer/LightlessSyncServer/Startup.cs @@ -295,7 +295,8 @@ public class Startup }, new List { MetricsAPI.GaugeAuthorizedConnections, - MetricsAPI.GaugeLightfinderConnections, + MetricsAPI.GaugeLightFinderConnections, + MetricsAPI.GaugeLightFinderGroups, MetricsAPI.GaugeConnections, MetricsAPI.GaugePairs, MetricsAPI.GaugePairsPaused, diff --git a/LightlessSyncServer/LightlessSyncShared/Metrics/MetricsAPI.cs b/LightlessSyncServer/LightlessSyncShared/Metrics/MetricsAPI.cs index 9139a55..fe97f72 100644 --- a/LightlessSyncServer/LightlessSyncShared/Metrics/MetricsAPI.cs +++ b/LightlessSyncServer/LightlessSyncShared/Metrics/MetricsAPI.cs @@ -9,7 +9,8 @@ public class MetricsAPI public const string GaugeAvailableIOWorkerThreads = "lightless_available_threadpool_io"; public const string GaugeUsersRegistered = "lightless_users_registered"; public const string CounterUsersRegisteredDeleted = "lightless_users_registered_deleted"; - public const string GaugeLightfinderConnections = "lightless_lightfinder_connections"; + public const string GaugeLightFinderConnections = "lightless_lightfinder_connections"; + public const string GaugeLightFinderGroups = "lightless_lightfinder_groups"; public const string GaugePairs = "lightless_pairs"; public const string GaugePairsPaused = "lightless_pairs_paused"; public const string GaugeFilesTotal = "lightless_files"; From 707c565ea938cb0b71e1f1cd33ffe95822e40393 Mon Sep 17 00:00:00 2001 From: CakeAndBanana Date: Wed, 15 Oct 2025 04:02:27 +0200 Subject: [PATCH 4/4] Inverted boolean for syncshells --- .../LightlessSyncServer/Services/SystemInfoService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LightlessSyncServer/LightlessSyncServer/Services/SystemInfoService.cs b/LightlessSyncServer/LightlessSyncServer/Services/SystemInfoService.cs index 4dc39cf..255fdb0 100644 --- a/LightlessSyncServer/LightlessSyncServer/Services/SystemInfoService.cs +++ b/LightlessSyncServer/LightlessSyncServer/Services/SystemInfoService.cs @@ -59,7 +59,7 @@ public sealed class SystemInfoService : BackgroundService var allLightfinderItems = _redis.GetAllAsync(allLightfinderKeys).GetAwaiter().GetResult(); var countLightFinderUsers = allLightfinderItems.Count; - var countLightFinderSyncshells = allLightfinderItems.Count(static l => string.IsNullOrEmpty(l.Value.GID)); + var countLightFinderSyncshells = allLightfinderItems.Count(static l => !string.IsNullOrEmpty(l.Value.GID)); SystemInfoDto = new SystemInfoDto() {