|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Tuesday, March 02, 2010 8:19 AM
Points: 10,
Visits: 16
|
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Monday, April 08, 2013 11:33 PM
Points: 13,
Visits: 39
|
|
For SQL Server 2008 you can execute the following query to obtain the server start time. This is a lot simpler than running a command line utility.
SELECT sqlserver_start_time FROM sys.dm_os_sys_info
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 9:30 AM
Points: 1,257,
Visits: 4,257
|
|
drikusvd (6/22/2010) For SQL Server 2008 you can execute the following query to obtain the server start time. This is a lot simpler than running a command line utility.
Well, except that gives you the time the SQL Server started, which isn't necessarily the same as the time the server started. Secondly, that won't work for a server that you might want to monitor that doesn't actually have SQL Server installed on it!
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Wednesday, March 06, 2013 12:56 AM
Points: 898,
Visits: 1,045
|
|
Secondly, that won't work for a server that you might want to monitor that doesn't actually have SQL Server installed on it!
Since I'm a DBA, i'm only interested in servers which have SQL installed (I only get payed for that) Another way to determine the uptime for SQL Server is to query the creation time from TempDB
Wilfred The best things in life are the simple things
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Wednesday, May 08, 2013 1:35 AM
Points: 139,
Visits: 4,605
|
|
As you said in the article, enable xp_cmdshell is not the best option and a solution would be to create a CLR function to get the uptime.
But, as the uptime it has nothing to do with SQL Server, because it's a Windows "function", it might be a good idea to get the information using a PowerShell script.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 5:53 AM
Points: 2,692,
Visits: 1,074
|
|
Powershell would be a good option and the one I'd pursue.
However for those that don't want to dabble in Powershell and don't want to enable xp_cmdshell, you can pipe the output from uptime into a text file and then use osql/sqlcmd to import the file into the DB.
Hope this helps Phill Carter -------------------- Colt 45 - the original point and click interface 
Australian SQL Server User Groups - My profile Phills Philosophies Murrumbeena Cricket Club
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Thursday, May 09, 2013 2:25 PM
Points: 956,
Visits: 873
|
|
The one problem we have with measuring uptime is that the server uptime doesn't necessarily mean the SQL Server was accessible at all times. We made a custom check to run from a centralized server to check connectivity every 9 minutes to make sure a simple select runs against master. However, it's hard to measure the pct of uptime strictly of SQL Server.
The logic I currently try to use it 100-((num_of_connectivity_failures/160)*100) = pct_uptime_for_connectivty_to_sql
1440 minutes in a day / 9 minutes = 160 connectivity checks per day.
For our missions critical systems, we check connectivity to the individual databases every minute, so the checks would be more 1440 checks per day and the percentage becomes more accurate.
Any other thoughts / suggestions are always welcomed though.
Steve
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Friday, April 12, 2013 12:32 AM
Points: 43,
Visits: 103
|
|
Good Article, uptime is sadly outdated and often crashes on Win2008
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, September 04, 2012 6:07 AM
Points: 6,
Visits: 21
|
|
I would highly recommend against enabling xp_cmdshell, enabling this feature just opens up a can of worms - especially when the SQL Server service is running under a privileged account like the LocalSystem user.
We use EventSentry (http://www.eventsentry.com) to track server uptime - it keeps a log of all reboots, shows graphs of server's uptimes (e.g. for comparison), logs the longest uptime for a server and more.
It also monitors services, if one wants to track the SQL Server services themselves.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, September 04, 2012 6:07 AM
Points: 6,
Visits: 21
|
|
|
|
|