Skip to content

Commit f2b7a80

Browse files
authored
Merge pull request #3381 from Montro1981/SQL-Server-First-Responder-Kit_3377-sp_MSgetalertinfo
#3377 Added a check for sp_MSgetalertinfo
2 parents 556a8e7 + 00f9173 commit f2b7a80

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
@@ -201,6 +201,7 @@ AS
201201
,@SkipModel bit = 0
202202
,@SkipTempDB bit = 0
203203
,@SkipValidateLogins bit = 0
204+
,@SkipGetAlertInfo bit = 0
204205

205206
DECLARE
206207
@db_perms table
@@ -226,6 +227,23 @@ AS
226227
/* End of declarations for First Responder Kit consistency check:*/
227228
;
228229

230+
/* Create temp table for check 73 */
231+
IF OBJECT_ID('tempdb..#AlertInfo') IS NOT NULL
232+
EXEC sp_executesql N'DROP TABLE #AlertInfo;';
233+
234+
CREATE TABLE #AlertInfo
235+
(
236+
FailSafeOperator NVARCHAR(255) ,
237+
NotificationMethod INT ,
238+
ForwardingServer NVARCHAR(255) ,
239+
ForwardingSeverity INT ,
240+
PagerToTemplate NVARCHAR(255) ,
241+
PagerCCTemplate NVARCHAR(255) ,
242+
PagerSubjectTemplate NVARCHAR(255) ,
243+
PagerSendSubjectOnly NVARCHAR(255) ,
244+
ForwardAlways INT
245+
);
246+
229247
/* Create temp table for check 2301 */
230248
IF OBJECT_ID('tempdb..#InvalidLogins') IS NOT NULL
231249
EXEC sp_executesql N'DROP TABLE #InvalidLogins;';
@@ -315,6 +333,20 @@ AS
315333
END CATCH;
316334
END; /*Need execute on sp_validatelogins*/
317335

336+
IF ISNULL(@SkipGetAlertInfo, 0) != 1 /*If @SkipGetAlertInfo hasn't been set to 1 by the caller*/
337+
BEGIN
338+
BEGIN TRY
339+
/* Try to fill the table for check 73 */
340+
INSERT INTO #AlertInfo
341+
EXEC [master].[dbo].[sp_MSgetalertinfo] @includeaddresses = 0;
342+
343+
SET @SkipGetAlertInfo = 0; /*We can execute sp_MSgetalertinfo*/
344+
END TRY
345+
BEGIN CATCH
346+
SET @SkipGetAlertInfo = 1; /*We have don't have execute rights or sp_MSgetalertinfo throws an error so skip it*/
347+
END CATCH;
348+
END; /*Need execute on sp_MSgetalertinfo*/
349+
318350
IF ISNULL(@SkipModel, 0) != 1 /*If @SkipModel hasn't been set to 1 by the caller*/
319351
BEGIN
320352
IF EXISTS
@@ -639,7 +671,13 @@ AS
639671
SELECT
640672
v.*
641673
FROM (VALUES(NULL, 2301, NULL)) AS v (DatabaseName, CheckID, ServerName) /*sp_validatelogins*/
642-
WHERE @SkipValidateLogins = 1
674+
WHERE @SkipValidateLogins = 1;
675+
676+
INSERT #SkipChecks (DatabaseName, CheckID, ServerName)
677+
SELECT
678+
v.*
679+
FROM (VALUES(NULL, 73, NULL)) AS v (DatabaseName, CheckID, ServerName) /*sp_validatelogins*/
680+
WHERE @SkipGetAlertInfo = 1;
643681

644682
IF @sa = 0
645683
BEGIN
@@ -8198,20 +8236,6 @@ IF @ProductVersionMajor >= 10
81988236

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

8201-
DECLARE @AlertInfo TABLE
8202-
(
8203-
FailSafeOperator NVARCHAR(255) ,
8204-
NotificationMethod INT ,
8205-
ForwardingServer NVARCHAR(255) ,
8206-
ForwardingSeverity INT ,
8207-
PagerToTemplate NVARCHAR(255) ,
8208-
PagerCCTemplate NVARCHAR(255) ,
8209-
PagerSubjectTemplate NVARCHAR(255) ,
8210-
PagerSendSubjectOnly NVARCHAR(255) ,
8211-
ForwardAlways INT
8212-
);
8213-
INSERT INTO @AlertInfo
8214-
EXEC [master].[dbo].[sp_MSgetalertinfo] @includeaddresses = 0;
82158239
INSERT INTO #BlitzResults
82168240
( CheckID ,
82178241
Priority ,
@@ -8226,7 +8250,7 @@ IF @ProductVersionMajor >= 10
82268250
'No Failsafe Operator Configured' AS Finding ,
82278251
'https://www.brentozar.com/go/failsafe' AS URL ,
82288252
( '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
8229-
FROM @AlertInfo
8253+
FROM #AlertInfo
82308254
WHERE FailSafeOperator IS NULL;
82318255
END;
82328256

@@ -10033,6 +10057,11 @@ IF @ProductVersionMajor >= 10 AND NOT EXISTS ( SELECT 1
1003310057
EXEC sp_executesql N'DROP TABLE #InvalidLogins;';
1003410058
END;
1003510059

10060+
IF OBJECT_ID('tempdb..#AlertInfo') IS NOT NULL
10061+
BEGIN
10062+
EXEC sp_executesql N'DROP TABLE #AlertInfo;';
10063+
END;
10064+
1003610065
/*
1003710066
Reset the Nmumeric_RoundAbort session state back to enabled if it was disabled earlier.
1003810067
See Github issue #2302 for more info.

0 commit comments

Comments
 (0)