I want to monitor the transaction logs of a database and send some kind of alert once a threshold is reached.
How can I do this?
I want to monitor the transaction logs of a database and send some kind of alert once a threshold is reached.
How can I do this?
Take a look at this tutorial about how to send mail from SQL server 2008 and configure your server accordingly.
Use the DBCC SQLPERF(logspace)
function to retreive the data for your transaction log size and usage and run sp_send_dbmail to send the alert to your desired mail address. Schedule using the SQL agent or via a scheduled task calling sqlcmd
to run periodically.
Use your favorite / currently employed monitoring system to watch the file / folder size and set thresholds for alerts.
Do not let your transaction log files grow excessively in the first place. Database or log backups will truncate the log upon completion, so run them regularly. Or change to the simple recovery model if you do not need point-in-time restores.