Skip to content

Commit 6c01da9

Browse files
Add Off collection preset and re-enable-all behavior for named presets (#888) (#891)
config.apply_collection_preset now accepts a fourth preset, Off, which sets enabled = 0 across every row in config.collection_schedule without touching frequencies. The three existing presets (Aggressive, Balanced, Low-Impact) now also set enabled = 1 on every row before applying their frequencies, so switching back from Off reliably resumes collection — including daily/on-load collectors not in the preset list. Pair with two SQL Agent jobs to compose time-of-day windows (apply Off at the start of a quiet window, apply a named preset to resume) without needing a scheduler feature in the collectors themselves. Heads up: applying a non-Off preset overrides any manual UPDATE config.collection_schedule SET enabled = 0 on a specific collector. Documented in the proc header. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 059180d commit 6c01da9

3 files changed

Lines changed: 58 additions & 16 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515

1616
- **Memory Pressure Events in Lite** — the collector, chart, and `get_memory_pressure_events` MCP tool previously only in the Full Edition are now available in Lite ([#865])
1717
- **Grid auto-scrolling** in Lite and Dashboard ([#843]) — thanks [@ClaudioESSilva](https://github.com/ClaudioESSilva)
18+
- **`Off` collection preset**`config.apply_collection_preset @preset_name = N'Off'` disables every collector in one call. Pair it with a second Agent job that applies a non-`Off` preset at the start of your active window to get overnight / quiet-hours scoping without writing scheduler code. Non-`Off` presets now also set `enabled = 1` across the board so the switch reliably resumes collection ([#888])
1819

1920
### Changed
2021

@@ -47,6 +48,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4748
[#865]: https://github.com/erikdarlingdata/PerformanceMonitor/issues/865
4849
[#867]: https://github.com/erikdarlingdata/PerformanceMonitor/issues/867
4950
[#872]: https://github.com/erikdarlingdata/PerformanceMonitor/issues/872
51+
[#888]: https://github.com/erikdarlingdata/PerformanceMonitor/issues/888
5052

5153
## [2.7.0] - 2026-04-13
5254

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ All release binaries are digitally signed via [SignPath](https://signpath.io)
5656

5757
## What You Get
5858

59-
🔍 **32 specialized T-SQL collectors** running on configurable schedules with named presets (Aggressive, Balanced, Low-Impact) — wait stats, query performance, blocking chains, deadlock graphs, memory grants, file I/O, tempdb, perfmon counters, FinOps/capacity, and more. Query text and execution plan collection can be disabled per-collector for sensitive environments.
59+
🔍 **32 specialized T-SQL collectors** running on configurable schedules with named presets (Off, Aggressive, Balanced, Low-Impact) — wait stats, query performance, blocking chains, deadlock graphs, memory grants, file I/O, tempdb, perfmon counters, FinOps/capacity, and more. Query text and execution plan collection can be disabled per-collector for sensitive environments. Switch presets with a pair of SQL Agent jobs to get quiet-hours / overnight windows without writing any code.
6060

6161
🚨 **Real-time alerts** for blocking, deadlocks, and high CPU — system tray notifications, styled HTML emails with full XML attachments, and webhook notifications for external integrations
6262

install/41_schedule_management.sql

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,18 @@ GO
142142

143143
/*
144144
Apply a named collection preset
145-
Changes all scheduled collector frequencies in one operation.
146-
Does not modify enabled/disabled state or daily/on-load collectors.
147145
148-
Valid preset names: Aggressive, Balanced, Low-Impact
146+
Valid preset names: Off, Aggressive, Balanced, Low-Impact
147+
148+
Off sets enabled = 0 on every row in config.collection_schedule and changes
149+
nothing else — no frequency edits. The other three set enabled = 1 on every
150+
row (so switching back from Off reliably reactivates collection) and update
151+
frequency_minutes for the collectors they list. Daily/on-load collectors
152+
that aren't in the preset keep their existing frequency.
153+
154+
Heads up: applying a non-Off preset overrides any manual
155+
UPDATE config.collection_schedule SET enabled = 0 on a specific collector.
156+
If that matters in your environment, re-disable it after switching presets.
149157
*/
150158
IF OBJECT_ID(N'config.apply_collection_preset', N'P') IS NULL
151159
BEGIN
@@ -169,9 +177,33 @@ BEGIN
169177
@rows_updated bigint = 0;
170178

171179
BEGIN TRY
172-
IF @preset_name NOT IN (N'Aggressive', N'Balanced', N'Low-Impact')
180+
IF @preset_name NOT IN (N'Off', N'Aggressive', N'Balanced', N'Low-Impact')
173181
BEGIN
174-
RAISERROR(N'Invalid preset name "%s". Valid presets: Aggressive, Balanced, Low-Impact', 16, 1, @preset_name);
182+
RAISERROR(N'Invalid preset name "%s". Valid presets: Off, Aggressive, Balanced, Low-Impact', 16, 1, @preset_name);
183+
RETURN;
184+
END;
185+
186+
/*
187+
Off disables every collector and exits. No frequency table needed.
188+
Pair with a second Agent job that applies a non-Off preset at the
189+
start of your active window to resume collection.
190+
*/
191+
IF @preset_name = N'Off'
192+
BEGIN
193+
UPDATE
194+
config.collection_schedule
195+
SET
196+
enabled = 0,
197+
modified_date = SYSDATETIME();
198+
199+
SET @rows_updated = ROWCOUNT_BIG();
200+
201+
IF @debug = 1
202+
BEGIN
203+
RAISERROR(N'Applied "Off" preset — %I64d collectors disabled', 0, 1, @rows_updated) WITH NOWAIT;
204+
END;
205+
206+
PRINT 'Applied "Off" collection preset (' + CONVERT(varchar(10), @rows_updated) + ' collectors disabled)';
175207
RETURN;
176208
END;
177209

@@ -303,20 +335,27 @@ BEGIN
303335
END;
304336

305337
/*
306-
Apply the preset to all matching collectors.
307-
Only updates frequency - does not change enabled/disabled state.
308-
Skips daily/on-load collectors not in the preset.
338+
Re-enable every collector first so a switch from Off → named preset
339+
reliably resumes collection, including daily/on-load collectors that
340+
aren't in the preset frequency table.
341+
*/
342+
UPDATE
343+
config.collection_schedule
344+
SET
345+
enabled = 1,
346+
modified_date = SYSDATETIME()
347+
WHERE
348+
enabled = 0;
349+
350+
/*
351+
Apply the preset frequencies to the collectors it lists.
352+
Daily/on-load collectors not in the preset keep their existing frequency.
309353
*/
310354
UPDATE
311355
cs
312356
SET
313357
cs.frequency_minutes = p.frequency_minutes,
314-
cs.next_run_time =
315-
CASE
316-
WHEN cs.enabled = 1
317-
THEN SYSDATETIME()
318-
ELSE cs.next_run_time
319-
END,
358+
cs.next_run_time = SYSDATETIME(),
320359
cs.modified_date = SYSDATETIME()
321360
FROM config.collection_schedule AS cs
322361
JOIN @preset AS p
@@ -416,11 +455,12 @@ PRINT '';
416455
PRINT 'Available procedures:';
417456
PRINT '- config.update_collector_frequency - Change frequency for specific collector';
418457
PRINT '- config.set_collector_enabled - Enable/disable specific collector';
419-
PRINT '- config.apply_collection_preset - Apply a named preset (Aggressive, Balanced, Low-Impact)';
458+
PRINT '- config.apply_collection_preset - Apply a named preset (Off, Aggressive, Balanced, Low-Impact)';
420459
PRINT '- config.show_collection_schedule - Display current schedule';
421460
PRINT '';
422461
PRINT 'Examples:';
423462
PRINT ' EXECUTE config.apply_collection_preset @preset_name = N''Aggressive'', @debug = 1;';
424463
PRINT ' EXECUTE config.apply_collection_preset @preset_name = N''Balanced'';';
425464
PRINT ' EXECUTE config.apply_collection_preset @preset_name = N''Low-Impact'';';
465+
PRINT ' EXECUTE config.apply_collection_preset @preset_name = N''Off''; -- disables all collectors';
426466
GO

0 commit comments

Comments
 (0)