SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


DBmail shut down and how to audit.


DBmail shut down and how to audit.

Poll
DBmail shut down and how to audit. Closed poll

28.57% - 2 votes We had an issue and was noticed until client inform.
28.57% 2 votes
71.43% - 5 votes Can someone help on how to audit who stopped it and how to configure alert when DBmail is stop.
71.43% 5 votes
Member votes: 7, Guest votes: 0. You don't have permission to vote in this poll
Author
Message
anzz
anzz
SSCarpal Tunnel
SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)

Group: General Forum Members
Points: 4909 Visits: 719
We had an issue and was noticed until client inform. [br]
Can someone help on how to audit who stopped it and how to configure alert when DBmail is stop.
Sue_H
Sue_H
SSC Guru
SSC Guru (69K reputation)SSC Guru (69K reputation)SSC Guru (69K reputation)SSC Guru (69K reputation)SSC Guru (69K reputation)SSC Guru (69K reputation)SSC Guru (69K reputation)SSC Guru (69K reputation)

Group: General Forum Members
Points: 69416 Visits: 14454
anzz - Wednesday, January 18, 2017 1:38 PM
We had an issue and was noticed until client inform. [br]
Can someone help on how to audit who stopped it and how to configure alert when DBmail is stop.

You can check the default trace files for ErrorLog event class and you will find the statement:
<timestamp> spidXX Configuration option 'Database Mail XPs' changed from 1 to 0. Run the RECONFIGURE statement to install.
The user name column will have the user.
It also gets logged to the SQL Server Error Log but won't have the user name in there. But you would look for the same statement that is in the trace.
In terms of auditing, it would be hard to send an alert when mail doesn't work so what we've usually done is have the alert setup through Windows monitoring tools, pretty much all of them can read the event logs and send alerts. It's logged to the Application Event log by default. The same statement:
Configuration option 'Database Mail XPs' changed from 1 to 0. Run the RECONFIGURE statement to install.
with the event ID 15457
Most of the times we've set this up they needed to do it by event id and source, depends on what it being used.

Sue




Chris Harshman
Chris Harshman
SSC-Dedicated
SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)

Group: General Forum Members
Points: 36243 Visits: 6944

Database mail uses a queue and Service Broker to handle the sending of mail, and it will activate when necessary. It is normal to see the process that handles this stop when it has nothing to do. Here's some queries to check:


USE msdb

-- see if enabled
SELECT * FROM sys.configurations
WHERE name = 'Database Mail XPs'

-- all messages
SELECT * FROM dbo.sysmail_allitems
WHERE send_request_date >= DATEADD(day, DATEDIFF(day, 0, GETDATE()), 0) --'2016-02-15'
ORDER BY send_request_date DESC

-- messages not sent in past day
SELECT * FROM dbo.sysmail_allitems
WHERE sent_date > GETDATE() - 1
AND sent_status <> 'sent'
ORDER BY send_request_date DESC

-- error log
SELECT i.mailitem_id, i.subject, i.send_request_date, l.log_date, i.body, i.file_attachments, l.description
FROM dbo.sysmail_faileditems as i
INNER JOIN dbo.sysmail_event_log AS l ON i.mailitem_id = l.mailitem_id
WHERE i.last_mod_date > GETDATE() - 1
ORDER BY i.send_request_date DESC, l.log_date DESC

-- unsent
SELECT * FROM dbo.sysmail_unsentitems



more detailed troubleshooting database mail:
https://technet.microsoft.com/en-us/library/ms189959(v=sql.105).aspx

to learn about database mail:
https://technet.microsoft.com/en-us/library/ms175887(v=sql.105).aspx


Ed Wagner
Ed Wagner
SSC Guru
SSC Guru (259K reputation)SSC Guru (259K reputation)SSC Guru (259K reputation)SSC Guru (259K reputation)SSC Guru (259K reputation)SSC Guru (259K reputation)SSC Guru (259K reputation)SSC Guru (259K reputation)

Group: General Forum Members
Points: 259896 Visits: 12221
Chris already posted most of what I would have said with querying the mail system tables. The only thing I'll add is how to check to see if the mail system is running.

EXECUTE msdb.dbo.sysmail_help_status_sp;



If the configuration Database Mail XPs isn't enabled, you won't be able to execute this procedure because it'll be blocked.


Tally Tables - Performance Personified
String Splitting with True Performance
Best practices on how to ask questions
anzz
anzz
SSCarpal Tunnel
SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)

Group: General Forum Members
Points: 4909 Visits: 719
Thanks for the reply.

how to monitor DBmail, I mean in terms of audit if the DBmail is stopped.
Lowell
Lowell
SSC Guru
SSC Guru (289K reputation)SSC Guru (289K reputation)SSC Guru (289K reputation)SSC Guru (289K reputation)SSC Guru (289K reputation)SSC Guru (289K reputation)SSC Guru (289K reputation)SSC Guru (289K reputation)

Group: General Forum Members
Points: 289422 Visits: 41976
anzz - Thursday, January 19, 2017 2:17 PM
Thanks for the reply.

how to monitor DBmail, I mean in terms of audit if the DBmail is stopped.



you missed the point above. it starts itself automatically when there's something int he queue, and turnns itself off after it is idle for a while.

what you should audit is failed mail: items that are in the sent mail with a status that is not sent, and dig intot eh specific errors to find out wher ethe issue is.

this is what i use; if it's been days or weeks since the last error, you are in good shape.
SELECT top 100
mail.send_request_date As SentDate,
sent_status As Reason,
err.[description],
mail.*
FROM [msdb].[dbo].[sysmail_allitems] mail
inner join [msdb].[dbo].[sysmail_event_log] err
ON err.mailitem_id = mail.mailitem_id
WHERE mail.sent_status <> 'sent'
order by mailitem_id desc


Lowell
--help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search