문제

I have a request from a client to incorporate SNMP Traps as the method for alerting in SQL Server. The only way I have found to do this is by using [dbo].[sp_add_alert] found in the [msdb] database.

-- Add Message in sysmessages to be used for the alert
EXEC sp_addmessage
 @msgnum = 2624470,
 @severity = 1,
 @msgtext = 'A DEV GOT SYSADMIN, RUN!',
 @lang = 'us_english',
 @with_log = 'TRUE'

-- Create an Alert for a user-defined message in sysmessages
EXEC msdb.dbo.sp_add_alert
 @name = N'Alert_For_UserDefined_Message', 
 @message_id = 2624470, 
 @severity = 0, 
 @enabled = 1,
 @include_event_description_in = 1,
 @raise_snmp_trap = 1, 
 @job_id = N'00000000-0000-0000-0000-000000000000'

 -- Raise error to trigger the Alert
 RAISERROR (2624470,-1,-1)

However, when I actually raise the error, I only receive the actual Message located in sysmessages.

Now, I'm not too familiar with SNMP Traps, but I feel as though there are some settings that would need to be defined; whether that be at the time of creating the alert or as settings in the server configuration. Am I missing something here?

I came across this forum thread and all I gathered from it was that after version 6.5 this feature stopped doing anything, but there is no documentation to support its lack of functionality.

도움이 되었습니까?

해결책

msdb.dbo.sp_add_alert calls msdb.dbo.sp_add_alert_internal, which in turn writes values into the msdb.dbo.sysalerts table.

The sysalerts table insert looks like this:

INSERT INTO msdb.dbo.sysalerts
         (name,
          event_source,
          event_category_id,
          event_id,
          message_id,
          severity,
          enabled,
          delay_between_responses,
          last_occurrence_date,
          last_occurrence_time,
          last_response_date,
          last_response_time,
          notification_message,
          include_event_description,
          database_name,
          event_description_keyword,
          occurrence_count,
          count_reset_date,
          count_reset_time,
          job_id,
          has_notification,
          flags,
          performance_condition,
          category_id)
  VALUES (@name,
          @event_source,
          @event_category_id,
          @event_id,
          @message_id,
          @severity,
          @enabled,
          @delay_between_responses,
          @last_occurrence_date,
          @last_occurrence_time,
          @last_notification_date,
          @last_notification_time,
          @notification_message,
          @include_event_description_in,
          @database_name,
          @event_description_keyword,
          @occurrence_count,
          @count_reset_date,
          @count_reset_time,
          ISNULL(@job_id, CONVERT(UNIQUEIDENTIFIER, 0x00)),
          @has_notification,
          @raise_snmp_trap,
          @performance_condition,
          @category_id)

The @raise_snmp_trap variable is populated and inserted into the table in the flags column. The documentation for dbo.sysalerts, at Microsoft Docs, says the flags column is "Reserved."

Since there appears to be no way to access SNMP properties, such as the "community name", "trap destination", etc through the user interface, I would guess SNMP is no longer supported.

In fact, according to Sean Gallardy - Microsoft (Premier Field Engineer):

...the definite answer is support was removed in 2000. Yes, at one point it existed but it no longer exists and even support when it existed was dubious at best. All extended stored procedures and associated DLLs were removed.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 dba.stackexchange
scroll top