Skip to content

Dashboard: port CpuAlertMode (Total/SqlOnly) from Lite (#1004)#1006

Merged
erikdarlingdata merged 2 commits into
devfrom
feature/dashboard-cpu-alert-mode-port
May 27, 2026
Merged

Dashboard: port CpuAlertMode (Total/SqlOnly) from Lite (#1004)#1006
erikdarlingdata merged 2 commits into
devfrom
feature/dashboard-cpu-alert-mode-port

Conversation

@erikdarlingdata
Copy link
Copy Markdown
Owner

Summary

Ports CpuAlertMode from Lite (PR #902) into Dashboard so the desktop dashboard's alert evaluator, overview card, chart, and email/tray text all agree on what "CPU" means. Default mode is Total non-idle CPU; users can flip to SQL Server only in Settings → Alerts.

What's in here

  • UserPreferences.cs — new CpuAlertMode enum + property (default Total). [JsonStringEnumConverter] keeps preferences.json readable.
  • SettingsWindow — "measured as" dropdown next to the CPU threshold (two options: total non-idle, SQL only).
  • ServerHealthStatus.CpuDisplayText — now renders "Total% (SQL X%)" when both values are known, matching Lite's overview card format.
  • MainWindow.CheckPerformanceAlerts (High CPU branch) — picks Total or SQL based on prefs; the tray notification text, the RecordAlert row, the email's currentValue, and the detailText all carry the Total CPU / SQL CPU qualifier (mirrors the Lite email-qualifier fix in PR Overview lanes: plot Total CPU alongside SQL CPU (#1004) #1005).
  • ResourceOverviewCpuChart — plots two series (SQL blue + Total orange), matching the Server Trends lanes change in PR Overview lanes: plot Total CPU alongside SQL CPU (#1004) #1005.
  • DatabaseService.GetDailySummaryAsync — date-parameterized path takes a CpuAlertMode arg and swaps the column in the high_cpu_events count + CPU_CRITICAL health check. DailySummaryContent reads the mode from prefs at refresh time.

What's deferred (intentional)

The report.daily_summary view (install/47_create_reporting_views.sql:297) still hardcodes sqlserver_cpu_utilization. It's hit when the daily-summary date picker is on "today" (the default landing case) and from MCP. Moving the view to total_cpu_utilization requires an upgrade migration, so it's a separate bug. For non-today date selections, the inline query honors the user's mode.

Test plan

  • Settings → Alerts: confirm the dropdown loads with the saved value and the "Total" / "SQL Only" choice round-trips through preferences.json.
  • Trigger a High CPU alert in each mode; confirm:
    • Tray bubble reads Total CPU at N% (or SQL CPU at N%).
    • Email "Current Value" reads N% (Total CPU) / N% (SQL CPU).
    • The metric used to evaluate the threshold matches the dropdown.
  • Overview → Resource Overview: confirm CPU chart shows two lines (blue + orange) with the legend reading SQL CPU % / Total CPU %.
  • Daily Summary: pick a non-today date — confirm high_cpu_events count differs between Total and SqlOnly modes on a server with non-trivial other_process_cpu.
  • Overview cards: confirm CPU cell reads 94% (SQL 60%) when both values are present.

Related to #1004. Companion to PR #1005 (lanes + Lite email qualifier).

Mirrors PR #902's Lite changes into Dashboard so the desktop dashboard
matches what the alert evaluates. Default is Total non-idle CPU.

- UserPreferences: CpuAlertMode enum (Total/SqlOnly, default Total) with
  JsonStringEnumConverter so preferences.json stays readable.
- Settings → Alerts: "measured as" dropdown next to CPU threshold.
- ServerHealthStatus.CpuDisplayText now shows "Total% (SQL X%)" when both
  values are known, matching Lite's overview-card format.
- High CPU alert evaluator: selects Total or SQL based on prefs and labels
  the metric in tray + email currentValue (e.g. "95% (Total CPU)"),
  mirroring the Lite fix that landed in PR #1005.
- ResourceOverviewCpuChart now plots two series (SQL blue + Total orange),
  matching the Server Trends lanes change in PR #1005.
- DatabaseService.GetDailySummaryAsync gains a CpuAlertMode parameter on
  the date-parameterized query path; DailySummaryContent reads the mode
  from prefs and passes it in. View path (used for today's no-date case
  and MCP) still uses SQL-only — separate follow-up tracks moving the
  view to total_cpu_utilization.
CREATE OR ALTER VIEW is re-run by the installer on every upgrade, so no
migration is needed. With the Dashboard now defaulting CpuAlertMode to
Total, the view's "today" no-date path (and MCP) now agree with the
alert metric rather than reporting SQL-only counts.

Users on SqlOnly mode still see Total-based counts on the no-date view
path — the view can't be per-user since it's a database object. The
date-parameterized path (DatabaseService.GetDailySummaryAsync with a
date) honors per-user mode and is unchanged here.
@erikdarlingdata erikdarlingdata merged commit 51de625 into dev May 27, 2026
6 checks passed
@erikdarlingdata erikdarlingdata deleted the feature/dashboard-cpu-alert-mode-port branch May 27, 2026 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant