Query for SQL uptime?
wullsy
Posts: 10
Hi,
I'd like to create an uptimeavailability report.
What I'd like is similar to what the front end captures i.e.
How long has SQL Monitor been able to connect to the instance?
I know I can capture how long the server or instance has been up however, ideally I'd like to know how long it's been accessible over the network.
Does anyone have some sample t-sql I can use to pull this information out of SQL Monitor db?
I'd like to create an uptimeavailability report.
What I'd like is similar to what the front end captures i.e.
How long has SQL Monitor been able to connect to the instance?
I know I can capture how long the server or instance has been up however, ideally I'd like to know how long it's been accessible over the network.
Does anyone have some sample t-sql I can use to pull this information out of SQL Monitor db?
Comments
I believe what you require can be implemented using the below script. Please try it out and let me know if you need anything further.
The uptime is based on SQL Monitor's ability to connect to the monitored entity, and also to collect data. The percentage and downtime measures are based on the times that SQL Monitor was attempting to connect, so the percentages and minutes will be accurate, but only cover the times SQL Monitor was instructed to monitor the server.
Eg: You monitor an instance for an hour, and it is online throughout this hour. If you then ask: "What is the uptime for this instance for the last week?", this script will report 100%, with 0 minutes uptime, even if there has been downtime the day before.
Dan Bainbridge
Product Support Engineer | Redgate Software
I've got a whole bunch of small outages that don't appear to show.
I would have thought that it might have shown 0.50000000000 rather than 0.00000000000 for downtime minutes for the example below.
SQL Server instance unreachable from: 6 Oct 2015 10:03:22 PM
SQL Server became reachable again at: 6 Oct 2015 10:03:54 PM
It's only 30 seconds so not the end of the world.
Did you edit the date range at the top of the script?
This should be edited to show the date range you would like to report on. This should be accurate to 5 seconds. Let me know how you get on when you try this.
Regards
Dan Bainbridge
Dan Bainbridge
Product Support Engineer | Redgate Software
Is the query mentioned in the earlier comment still valid? I am getting a lot of syntax errors when I try to execute the query.