forked from SQLUndercover/UndercoverToolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHigh Severity Alert Notifications.sql
157 lines (127 loc) · 5.16 KB
/
High Severity Alert Notifications.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/******************************************************************
Your SQL Server's Screaming But Is Anyone Listening? - High Severity Alert Notifications
https://sqlundercover.com/2020/01/30/your-sql-servers-screaming-but-is-anyone-listening-high-severity-alert-notifications/
Author: David Fowler
Revision date: 30/01/2020
Version: 1.0
© www.sqlundercover.com
This script is for personal, educational, and internal
corporate purposes, provided that this header is preserved. Redistribution or sale
of this script,in whole or in part, is prohibited without the author's express
written consent.
The software is provided "as is", without warranty of any kind, express or
implied, including but not limited to the warranties of merchantability,
fitness for a particular purpose and noninfringement. in no event shall the
authors or copyright holders be liable for any claim, damages or other
liability, whether in an action of contract, tort or otherwise, arising from,
out of or in connection with the software or the use or other dealings in the
software.
******************************************************************/
USE [msdb]
GO
--Create High Severity Error category
EXEC sp_add_category
@class = N'ALERT',
@type = N'NONE',
@name = N'High Severity Error'
GO
--Configure alerts
EXEC msdb.dbo.sp_add_alert @name=N'URGENT: Severity 17 Error:',
@message_id=0,
@severity=17,
@enabled=1,
@delay_between_responses=0,
@include_event_description_in=1,
@category_name=N'High Severity Error'
GO
EXEC msdb.dbo.sp_add_alert @name=N'URGENT: Severity 18 Error: Nonfatal Internal Error',
@message_id=0,
@severity=18,
@enabled=1,
@delay_between_responses=0,
@include_event_description_in=1,
@category_name=N'High Severity Error'
GO
EXEC msdb.dbo.sp_add_alert @name=N'URGENT: Severity 19 Error: Fatal Error in Resource',
@message_id=0,
@severity=19,
@enabled=1,
@delay_between_responses=0,
@include_event_description_in=1,
@category_name=N'High Severity Error'
GO
EXEC msdb.dbo.sp_add_alert @name=N'URGENT: Severity 20 Error: Fatal Error in Current Process',
@message_id=0,
@severity=20,
@enabled=1,
@delay_between_responses=0,
@include_event_description_in=1,
@category_name=N'High Severity Error'
GO
EXEC msdb.dbo.sp_add_alert @name=N'URGENT: Severity 21 Error: Fatal Error in Database Process',
@message_id=0,
@severity=21,
@enabled=1,
@delay_between_responses=0,
@include_event_description_in=1,
@category_name=N'High Severity Error'
GO
EXEC msdb.dbo.sp_add_alert @name=N'URGENT: Severity 22 Error Fatal Error: Table Integrity Suspect',
@message_id=0,
@severity=22,
@enabled=1,
@delay_between_responses=0,
@include_event_description_in=1,
@category_name=N'High Severity Error'
GO
EXEC msdb.dbo.sp_add_alert @name=N'URGENT: Severity 23 Error: Fatal Error Database Integrity Suspect',
@message_id=0,
@severity=23,
@enabled=1,
@delay_between_responses=0,
@include_event_description_in=1,
@category_name=N'High Severity Error'
GO
EXEC msdb.dbo.sp_add_alert @name=N'URGENT: Severity 24 Error: Fatal Hardware Error',
@message_id=0,
@severity=24,
@enabled=1,
@delay_between_responses=0,
@include_event_description_in=1,
@category_name=N'High Severity Error'
GO
EXEC msdb.dbo.sp_add_alert @name=N'URGENT: Severity 25 Error: Fatal Error',
@message_id=0,
@severity=25,
@enabled=1,
@delay_between_responses=0,
@include_event_description_in=1,
@category_name=N'High Severity Error'
GO
--Configure operator
USE msdb;
GO
EXEC msdb.dbo.sp_add_operator
@name = 'SQLUndercoverDBAs',
@enabled = 1,
@email_address = '[email protected]';
GO
--setup notifications
EXEC dbo.sp_add_notification
@alert_name = N'URGENT: Severity 17 Error:', @operator_name = N'SQLUndercoverDBAs', @notification_method = 1 ;
EXEC dbo.sp_add_notification
@alert_name = N'URGENT: Severity 18 Error: Nonfatal Internal Error', @operator_name = N'SQLUndercoverDBAs', @notification_method = 1 ;
EXEC dbo.sp_add_notification
@alert_name = N'URGENT: Severity 19 Error: Fatal Error in Resource', @operator_name = N'SQLUndercoverDBAs', @notification_method = 1 ;
EXEC dbo.sp_add_notification
@alert_name = N'URGENT: Severity 20 Error: Fatal Error in Current Process', @operator_name = N'SQLUndercoverDBAs', @notification_method = 1 ;
EXEC dbo.sp_add_notification
@alert_name = N'URGENT: Severity 21 Error: Fatal Error in Database Process', @operator_name = N'SQLUndercoverDBAs', @notification_method = 1 ;
EXEC dbo.sp_add_notification
@alert_name = N'URGENT: Severity 22 Error Fatal Error: Table Integrity Suspect', @operator_name = N'SQLUndercoverDBAs', @notification_method = 1 ;
EXEC dbo.sp_add_notification
@alert_name = N'URGENT: Severity 23 Error: Fatal Error Database Integrity Suspect', @operator_name = N'SQLUndercoverDBAs', @notification_method = 1 ;
EXEC dbo.sp_add_notification
@alert_name = N'URGENT: Severity 24 Error: Fatal Hardware Error', @operator_name = N'SQLUndercoverDBAs', @notification_method = 1 ;
EXEC dbo.sp_add_notification
@alert_name = N'URGENT: Severity 25 Error: Fatal Error', @operator_name = N'SQLUndercoverDBAs', @notification_method = 1 ;