|
- @if (i.IsFailing)
+ @if (i.Paused)
+ {
+ Sat på pause
+ }
+ else if (i.IsFailing)
{
Fejler
}
@@ -49,6 +53,10 @@ else
| @i.Name @i.ServerName |
@(i.ProductVersion is null ? "–" : Display.Release(i.ProductVersion, i.EngineEdition)) @i.ProductVersion @i.ProductLevel @i.ProductUpdateLevel |
+ @if (i.Paused)
+ {
+ sidste data før pausen
+ }
@if (i.Critical > 0) { }
@if (i.High > 0) { }
@if (i.Medium > 0) { }
@@ -70,13 +78,20 @@ else
@code {
private IReadOnlyList _instances = [];
+ private IReadOnlyList _monitored = [];
+ private int _paused;
private IReadOnlyList _active = [];
private IReadOnlyList _urgent = [];
protected override async Task OnInitializedAsync()
{
- _instances = await Repository.GetInstancesAsync();
- _active = await Repository.GetActiveFindingsAsync();
+ // Removed instances are left out (their history stays for reports); paused ones are shown, marked, but do not
+ // count in the totals, the urgent findings or the privilege alert.
+ _instances = (await Repository.GetInstancesAsync()).Where(i => !i.Removed).ToList();
+ _monitored = _instances.Where(i => i.IsMonitored).ToList();
+ _paused = _instances.Count(i => i.Paused);
+ var monitoredIds = _monitored.Select(i => i.InstanceId).ToHashSet();
+ _active = (await Repository.GetActiveFindingsAsync()).Where(f => monitoredIds.Contains(f.InstanceId)).ToList();
_urgent = _active.Where(f => f.Severity >= Severity.High).ToList();
}
}
diff --git a/src/SQLInsight.Web/Components/Pages/Instance.razor b/src/SQLInsight.Web/Components/Pages/Instance.razor
index 2b32168..0c13a89 100644
--- a/src/SQLInsight.Web/Components/Pages/Instance.razor
+++ b/src/SQLInsight.Web/Components/Pages/Instance.razor
@@ -24,9 +24,18 @@
Fejllog
+@if (_instance.Removed)
+{
+ Instansen er fjernet under Servere og databaser og overvåges ikke længere. Det, der blev indsamlet, vises her og i rapporterne.
+}
+else if (_instance.Paused)
+{
+ Sat på pause. Overvågningen er sat på pause under Servere og databaser. Det, der står her, er de seneste data før pausen; der kommer ingen nye fund eller alarmer.
+}
+
-@if (_instance.IsFailing)
+@if (_instance.IsFailing && _instance.IsMonitored)
{
Seneste forsøg på at nå instansen fejlede (@Display.Time(_instance.LastErrorAt)):
diff --git a/src/SQLInsight.Web/wwwroot/app.css b/src/SQLInsight.Web/wwwroot/app.css
index 49ee481..697a40c 100644
--- a/src/SQLInsight.Web/wwwroot/app.css
+++ b/src/SQLInsight.Web/wwwroot/app.css
@@ -237,3 +237,4 @@ button.button:hover { filter: brightness(1.08); }
button.button.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
button.button.danger { background: var(--critical); }
tr.muted td { color: var(--text-2); }
+.instances tr.paused td { opacity: .7; }
diff --git a/tests/SQLInsight.IntegrationTests/InstanceConfigurationRepositoryTests.cs b/tests/SQLInsight.IntegrationTests/InstanceConfigurationRepositoryTests.cs
index c0e0a6f..a67ea95 100644
--- a/tests/SQLInsight.IntegrationTests/InstanceConfigurationRepositoryTests.cs
+++ b/tests/SQLInsight.IntegrationTests/InstanceConfigurationRepositoryTests.cs
@@ -158,6 +158,30 @@ public class InstanceConfigurationRepositoryTests(SqlServerFixture sql) : IAsync
Assert.Equal(2, (await _repository.GetConfiguredInstancesAsync()).Count);
}
+ [Fact]
+ public async Task The_overview_knows_which_instances_are_paused_or_removed()
+ {
+ var now = DateTimeOffset.UtcNow;
+ var paused = await _repository.AddConfiguredInstanceAsync(Instance("paused-sql"), null, now);
+ var removed = await _repository.AddConfiguredInstanceAsync(Instance("removed-sql"), null, now);
+ foreach (var name in new[] { "paused-sql", "removed-sql", "before-1.3" })
+ {
+ await _repository.RecordInstanceErrorAsync(name, "x", now);
+ }
+
+ await _repository.SetInstancePausedAsync(paused, true, null, now);
+ await _repository.RemoveConfiguredInstanceAsync(removed, null, now);
+
+ var overview = (await _repository.GetInstancesAsync()).ToDictionary(i => i.Name);
+ Assert.Equal((true, false), (overview["paused-sql"].Paused, overview["paused-sql"].Removed));
+ Assert.Equal((false, true), (overview["removed-sql"].Paused, overview["removed-sql"].Removed));
+ Assert.True(overview["before-1.3"].IsMonitored);
+
+ // Added again under the same name: monitored again, with its history.
+ await _repository.AddConfiguredInstanceAsync(Instance("removed-sql"), null, now);
+ Assert.True((await _repository.GetInstanceAsync("removed-sql"))!.IsMonitored);
+ }
+
[Fact]
public async Task A_request_is_claimed_once_and_stale_ones_are_failed_with_a_reason()
{
diff --git a/tests/SQLInsight.IntegrationTests/InstanceSetupWebTests.cs b/tests/SQLInsight.IntegrationTests/InstanceSetupWebTests.cs
index 1cf5271..226f91a 100644
--- a/tests/SQLInsight.IntegrationTests/InstanceSetupWebTests.cs
+++ b/tests/SQLInsight.IntegrationTests/InstanceSetupWebTests.cs
@@ -68,6 +68,31 @@ public sealed partial class InstanceSetupWebTests(SqlServerFixture sql) : IAsync
private static int IdFrom(HttpResponseMessage response) =>
int.Parse(Regex.Match(response.Headers.Location!.OriginalString, @"/opsaetning/instanser/(\d+)").Groups[1].Value, System.Globalization.CultureInfo.InvariantCulture);
+ [Fact]
+ public async Task Overview_marks_paused_servers_and_leaves_out_removed_ones_and_so_do_the_alerts()
+ {
+ var now = DateTimeOffset.UtcNow;
+ var paused = await _repository.AddConfiguredInstanceAsync(new NewConfiguredInstance("paused-sql", "sql05", null, "Windows", null, null, null, "Mandatory", false, false), "anna", now);
+ var removed = await _repository.AddConfiguredInstanceAsync(new NewConfiguredInstance("removed-sql", "sql06", null, "Windows", null, null, null, "Mandatory", false, false), "anna", now);
+ await _repository.RecordInstanceErrorAsync("paused-sql", "kan ikke nås", now);
+ await _repository.RecordInstanceErrorAsync("removed-sql", "kan ikke nås", now);
+ await _repository.SetInstancePausedAsync(paused, true, "anna", now);
+ await _repository.RemoveConfiguredInstanceAsync(removed, "anna", now);
+
+ var home = await Client().GetStringAsync("/");
+ var metrics = await Client().GetStringAsync("/metrics");
+
+ Assert.Contains("paused-sql", home, StringComparison.Ordinal);
+ Assert.Contains("Sat på pause", home, StringComparison.Ordinal);
+ Assert.DoesNotContain("removed-sql", home, StringComparison.Ordinal);
+ Assert.Contains("sqlinsight_instance_paused{instance=\"paused-sql\"} 1", metrics, StringComparison.Ordinal);
+ Assert.DoesNotContain("sqlinsight_instance_up{instance=\"paused-sql\"}", metrics, StringComparison.Ordinal);
+ Assert.DoesNotContain("removed-sql", metrics, StringComparison.Ordinal);
+
+ // The history is still there.
+ Assert.Contains("fjernet", await Client().GetStringAsync("/instanser/removed-sql"), StringComparison.Ordinal);
+ }
+
[Fact]
public async Task Page_lists_servers_from_the_configuration_file_and_the_web_and_the_menu_links_to_it()
{
|