Skip to content

Commit 26f701c

Browse files
committed
#3377 Added a check for sp_MSgetalertinfo
1 parent 4bb747a commit 26f701c

File tree

1 file changed

+45
-16
lines changed

1 file changed

+45
-16
lines changed

sp_Blitz.sql

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ AS
200200
,@SkipModel bit = 0
201201
,@SkipTempDB bit = 0
202202
,@SkipValidateLogins bit = 0
203+
,@SkipGetAlertInfo bit = 0
203204
/* Variables for check 211: */
204205
,@powerScheme varchar(36)
205206
,@cpu_speed_mhz int
@@ -229,6 +230,23 @@ AS
229230
/* End of declarations for First Responder Kit consistency check:*/
230231
;
231232

233+
/* Create temp table for check 73 */
234+
IF OBJECT_ID('tempdb..#AlertInfo') IS NOT NULL
235+
EXEC sp_executesql N'DROP TABLE #AlertInfo;';
236+
237+
CREATE TABLE #AlertInfo
238+
(
239+
FailSafeOperator NVARCHAR(255) ,
240+
NotificationMethod INT ,
241+
ForwardingServer NVARCHAR(255) ,
242+
ForwardingSeverity INT ,
243+
PagerToTemplate NVARCHAR(255) ,
244+
PagerCCTemplate NVARCHAR(255) ,
245+
PagerSubjectTemplate NVARCHAR(255) ,
246+
PagerSendSubjectOnly NVARCHAR(255) ,
247+
ForwardAlways INT
248+
);
249+
232250
/* Create temp table for check 2301 */
233251
IF OBJECT_ID('tempdb..#InvalidLogins') IS NOT NULL
234252
EXEC sp_executesql N'DROP TABLE #InvalidLogins;';
@@ -350,6 +368,20 @@ AS
350368
END CATCH;
351369
END; /*Need execute on sp_validatelogins*/
352370

371+
IF ISNULL(@SkipGetAlertInfo, 0) != 1 /*If @SkipGetAlertInfo hasn't been set to 1 by the caller*/
372+
BEGIN
373+
BEGIN TRY
374+
/* Try to fill the table for check 73 */
375+
INSERT INTO #AlertInfo
376+
EXEC [master].[dbo].[sp_MSgetalertinfo] @includeaddresses = 0;
377+
378+
SET @SkipGetAlertInfo = 0; /*We can execute sp_MSgetalertinfo*/
379+
END TRY
380+
BEGIN CATCH
381+
SET @SkipGetAlertInfo = 1; /*We have don't have execute rights or sp_MSgetalertinfo throws an error so skip it*/
382+
END CATCH;
383+
END; /*Need execute on sp_MSgetalertinfo*/
384+
353385
IF ISNULL(@SkipModel, 0) != 1 /*If @SkipModel hasn't been set to 1 by the caller*/
354386
BEGIN
355387
IF EXISTS
@@ -628,7 +660,13 @@ AS
628660
SELECT
629661
v.*
630662
FROM (VALUES(NULL, 2301, NULL)) AS v (DatabaseName, CheckID, ServerName) /*sp_validatelogins*/
631-
WHERE @SkipValidateLogins = 1
663+
WHERE @SkipValidateLogins = 1;
664+
665+
INSERT #SkipChecks (DatabaseName, CheckID, ServerName)
666+
SELECT
667+
v.*
668+
FROM (VALUES(NULL, 73, NULL)) AS v (DatabaseName, CheckID, ServerName) /*sp_validatelogins*/
669+
WHERE @SkipGetAlertInfo = 1;
632670

633671
IF @SkipChecksTable IS NOT NULL
634672
AND @SkipChecksSchema IS NOT NULL
@@ -8181,20 +8219,6 @@ IF @ProductVersionMajor >= 10
81818219

81828220
IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 73) WITH NOWAIT;
81838221

8184-
DECLARE @AlertInfo TABLE
8185-
(
8186-
FailSafeOperator NVARCHAR(255) ,
8187-
NotificationMethod INT ,
8188-
ForwardingServer NVARCHAR(255) ,
8189-
ForwardingSeverity INT ,
8190-
PagerToTemplate NVARCHAR(255) ,
8191-
PagerCCTemplate NVARCHAR(255) ,
8192-
PagerSubjectTemplate NVARCHAR(255) ,
8193-
PagerSendSubjectOnly NVARCHAR(255) ,
8194-
ForwardAlways INT
8195-
);
8196-
INSERT INTO @AlertInfo
8197-
EXEC [master].[dbo].[sp_MSgetalertinfo] @includeaddresses = 0;
81988222
INSERT INTO #BlitzResults
81998223
( CheckID ,
82008224
Priority ,
@@ -8209,7 +8233,7 @@ IF @ProductVersionMajor >= 10
82098233
'No Failsafe Operator Configured' AS Finding ,
82108234
'https://www.brentozar.com/go/failsafe' AS URL ,
82118235
( 'No failsafe operator is configured on this server. This is a good idea just in-case there are issues with the [msdb] database that prevents alerting.' ) AS Details
8212-
FROM @AlertInfo
8236+
FROM #AlertInfo
82138237
WHERE FailSafeOperator IS NULL;
82148238
END;
82158239

@@ -9957,6 +9981,11 @@ IF @ProductVersionMajor >= 10 AND NOT EXISTS ( SELECT 1
99579981
EXEC sp_executesql N'DROP TABLE #InvalidLogins;';
99589982
END;
99599983

9984+
IF OBJECT_ID('tempdb..#AlertInfo') IS NOT NULL
9985+
BEGIN
9986+
EXEC sp_executesql N'DROP TABLE #AlertInfo;';
9987+
END;
9988+
99609989
/*
99619990
Reset the Nmumeric_RoundAbort session state back to enabled if it was disabled earlier.
99629991
See Github issue #2302 for more info.

0 commit comments

Comments
 (0)