I'm trying to find a way to monitor data and log file size from SQL Server databases (within an SQL Server instance). I would not want to use third party tools, but simply pure SQL or PowerShell. I know that one can query this data from sys.database_files or use DBCC SQLPERF(logspace) to get data from log file usage. Is there any way to automate this monitoring and get reports from this data? Any ideas and code samples are helpful!
Sql-server – How to monitor SQL Server data and log file growth
powershellsql serversql-server-2008transaction-log
Related Question
- Sql-server – Monitor Database Memory usage SQL Server
- Sql-server – Log file shrink attempts are futile
- Sql-server – How to collect NTFS file properties and insert into SQL Server table
- Sql-server – Cannot get LOB data from SQL Server transaction logs
- Sql-server – Autogrowth and Initial Size with T-Log
- Sql-server – How to Monitor Transaction Log Usage In SQL Server
Best Answer
If you want to use PowerShell you can easily create task scheduler jobs in Windows to run the PowerShell scripts which would dump the output into a table or log file.
If you want to use SQL you can easily create SQL Server Agent jobs to pull the data from the DMVs or DBCC and dump them in a table.
It is difficult to understand exactly what you would want any reports against the stored data to look like, or which part is challenging.