Uptime Report

by Jan 29, 2021

I've been working on a little project on my own that I thought I would share with the public. The project is essentially creating a report that would generally display how long a server had been up between two different times.  In other words, an uptime report. I know that there's a report that's currently built into SQL Diagnostic Manager so I decided to go a different route. For my report, it was going to be based on a custom counter that I would create. The custom counter would simply collect the number of minutes since the SQL Server instance has started. I've attached the custom counter below.


After creating the custom counter, I then link the custom counter to the instances that I'm monitoring with SQL Diagnostic Manager. At that point, I just let SQL Diagnostic Manager do its thing. After some time has passed, I then tried to create my own T-SQL script which would query the SQLdm Repository Database to give me a general uptime report. Before I show you the script, I want to point out that I'm not exactly fluent with T-SQL. I'm pretty sure things could have been written better and I'm hoping some of you will help improve the script. With that out of the way, here's my script.


The script itself does require some input. Right now, it takes one instance at a time and reports the uptime statistics between the dates that you supply. 

If this piques your interest, please do give it a try and let me know if you have any suggestions on how it could be improved!