SQL Server Alert发送告警邮件丢失了的故

前不久突然发现我们配备于数据库方面的报警(Alert),当错误日志里出现谬误时,并无是每个错误日志都见面发送邮件出来。如下所示,设置了报警“SQL
Server Severity Event 14”

 

USE
[msdb]

GO

 

 

IF
NOT EXISTS(SELECT 1 FROM msdb.dbo.syscategories WHERE NAME=’DBA_MONITORING’ AND category_class=2)

BEGIN

 

EXEC
msdb.dbo.sp_add_category

    @class=N’ALERT’,

    @type=N’NONE’,

    @name=N’DBA_MONITORING’ ;

 

END

GO

 

IF
EXISTS(SELECT name FROM msdb.dbo.sysalerts WHERE name= N’SQL Server Severity Event
14′)

 

    EXEC msdb.dbo.sp_delete_alert @name=N’SQL Server Severity Event
14′

GO

 

 

EXEC
msdb.dbo.sp_add_alert @name=N’SQL Server Severity Event
14′,

       
@message_id=0,

       
@severity=14,

       
@enabled=1,

       
@delay_between_responses=60,

       
@include_event_description_in=1,

       
@category_name=N’DBA_MONITORING’,

       
@job_id=N’00000000-0000-0000-0000-000000000000′

GO

 

 

EXEC
msdb.dbo.sp_add_notification @alert_name=N’SQL Server Severity Event
14′,
@operator_name=N’YourSQLDba_Operator’, @notification_method
= 1

GO

 

 

下一场我尝试用sa登录(sa已经给剥夺)了三不善,但是本人不过接收了同等查封邮件。特意查看了瞬间sp_add_alert的合法文档,才知晓出现是原因,是盖参数@delay_between_responses的价值设置由,通过安装该值,可以防范以在短缺日内再次发送一些请勿待之电子邮件。如齐所示,一分钟内,即使不当日志中出现了大气接近的谬误,也单独见面发送一查封报警邮件。其实只有是为着削减发送告警的效率,如果您想当错误日志里出现这个级别的报警时,都须发送告警邮件,可以以那个价值设置为0。但是有时,如果安为0,你晤面接多样之邮件。其实是有点问题,只是因为以前尚未特别注意这参数而已。存粹属于没有根了解这些功能罢了。

 

 

 

皇冠直营现金网开户 1

 

 

 

@delay_between_responses
=

] delay_between_responses

The
wait period, in seconds, between responses to the alert.
delay_between_responsesis int, with a default of 0, which
means there is no waiting between responses (each occurrence of the
alert generates a response). The response can be in either or both of
these forms:

·        
 

·        
One
or more notifications sent through e-mail or pager.

·        
 

·        
A
job to execute.

·        
By
setting this value, it is possible to prevent, for example, unwanted
e-mail messages from being sent when an alert repeatedly occurs in a
short period of time.

 

@delay_between_responses
=] delay_between_responses

警报响应期间的守候时
(以秒为单位)。delay_between_responsesis int, 默认值为 0,
这意味在响应期间无等待
(每次出现警报都见面扭转响应)。响应得以是当以下简单种形式中的一个,
或者都是:

透过电子皇冠直营现金网开户邮件或寻呼机发送的一个或者多只关照。

比方履的作业。

通过设置此值,
可以防范例如, 在短缺日外再发生警报时发送不需之电子邮件。

 

 

参考资料:

 

https://docs.microsoft.com/zh-cn/sql/relational-databases/system-stored-procedures/sp-add-alert-transact-sql

相关文章