Mail Fetching - Poll SQL database for failure
Hi
Just wrote this and thought I would share in case any one else can use it.
Change the error log id to the max value then create a SQL job that runs every 5 minutes or so -
Now you will be emailed if the SDP fetching service goes down or gets an error.
- USE SERVICEDESK
- GO
- DECLARE @sub VARCHAR(100);
- DECLARE @qry VARCHAR(1000);
- DECLARE @msg VARCHAR(250);
- IF EXISTS(select * from errorlog where message like '%MAIL_FETCHING%' AND PROBABLECAUSE LIKE 'Fetching stopped due to an error% AND ERRORLOGID > "603016"')
- begin
- SELECT @sub = 'SERVICEDESK MAIL FAILURE - OPEN AND START FETCHING';
- SELECT @msg = 'SERVICEDESK MAIL FETCHING FAILURE'
- EXEC msdb.dbo.sp_send_dbmail
- @profile_name = 'your_mail_profile',
- @recipients = 'your_email_address',
- @body = @msg,
- @subject = @sub,
- @query_result_header = 1,
- @query_result_width = 256,
- @query_result_separator = ' ',
- @query_result_no_padding = 1;
- END
New to ADSelfService Plus?