Skip to content

Commit

Permalink
Merge pull request #374 from erikdarlingdata/dev
Browse files Browse the repository at this point in the history
Update sp_PressureDetector.sql
  • Loading branch information
erikdarlingdata authored Mar 5, 2024
2 parents 4a3a182 + d82412f commit 633a3f0
Showing 1 changed file with 80 additions and 38 deletions.
118 changes: 80 additions & 38 deletions sp_PressureDetector/sp_PressureDetector.sql
Original file line number Diff line number Diff line change
Expand Up @@ -776,54 +776,96 @@ OPTION(MAXDOP 1, RECOMPILE);',
EXEC sys.sp_executesql
@disk_check;

SELECT
fm.hours_uptime,
fm.drive,
fm.database_name,
fm.database_file_details,
fm.file_size_gb,
fm.avg_read_stall_ms,
fm.avg_write_stall_ms,
fm.total_gb_read,
fm.total_gb_written,
total_read_count =
REPLACE
(
CONVERT
WITH
file_metrics AS
(
SELECT
fm.hours_uptime,
fm.drive,
fm.database_name,
fm.database_file_details,
fm.file_size_gb,
fm.avg_read_stall_ms,
fm.avg_write_stall_ms,
fm.total_gb_read,
fm.total_gb_written,
total_read_count =
REPLACE
(
nvarchar(30),
CONVERT
(
money,
fm.total_read_count
nvarchar(30),
CONVERT
(
money,
fm.total_read_count
),
1
),
1
N'.00',
N''
),
N'.00',
N''
),
total_write_count =
REPLACE
(
CONVERT
total_write_count =
REPLACE
(
nvarchar(30),
CONVERT
(
money,
fm.total_write_count
nvarchar(30),
CONVERT
(
money,
fm.total_write_count
),
1
),
1
N'.00',
N''
),
N'.00',
N''
)
FROM @file_metrics AS fm
WHERE fm.avg_read_stall_ms > @minimum_disk_latency_ms
OR fm.avg_write_stall_ms > @minimum_disk_latency_ms
ORDER BY
fm.avg_read_stall_ms +
fm.avg_write_stall_ms DESC;
total_avg_stall_ms =
fm.avg_read_stall_ms +
fm.avg_write_stall_ms
FROM @file_metrics AS fm
WHERE fm.avg_read_stall_ms > @minimum_disk_latency_ms
OR fm.avg_write_stall_ms > @minimum_disk_latency_ms
)
SELECT
fm.hours_uptime,
fm.drive,
fm.database_name,
fm.database_file_details,
fm.file_size_gb,
fm.avg_read_stall_ms,
fm.avg_write_stall_ms,
fm.total_gb_read,
fm.total_gb_written,
fm.total_read_count,
fm.total_write_count,
fm.total_avg_stall_ms
FROM file_metrics AS fm

UNION ALL

SELECT
hours_uptime = 0,
drive = N'Nothing to see here',
database_name = N'By default, only >100 ms latency is reported',
database_file_details = N'Use the @minimum_disk_latency_ms parameter to adjust what you see',
file_size_gb = 0,
avg_read_stall_ms = 0,
avg_write_stall_ms = 0,
total_gb_read = 0,
total_gb_written = 0,
total_read_count = N'0',
total_write_count = N'0',
total_avg_stall = 0
WHERE NOT EXISTS
(
SELECT
1/0
FROM file_metrics AS fm
)
ORDER BY
total_avg_stall_ms DESC;
END; /*End file stats*/

/*
Expand Down

0 comments on commit 633a3f0

Please sign in to comment.