﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by Richard  Pless  / Using the UPTIME Utility to Monitor Servers / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Wed, 22 May 2013 06:09:09 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Using the UPTIME Utility to Monitor Servers</title><link>http://www.sqlservercentral.com/Forums/Topic941473-2723-1.aspx</link><description>Since tempdb is created everytime the SQL Services are started, why not just check sys.databases? ie: select create_date from sys.databases where name='tempdb'</description><pubDate>Thu, 24 Jun 2010 13:59:19 GMT</pubDate><dc:creator>tew</dc:creator></item><item><title>RE: Using the UPTIME Utility to Monitor Servers</title><link>http://www.sqlservercentral.com/Forums/Topic941473-2723-1.aspx</link><description>I didn't actually know that only sysadmins can run it, but I believe one can give other users the right to execute xp_cmdshell, or at least this was possible in earlier versions.I think why the security community doesn't like it, is simply because the benefits don't outweigh the risks, and because a lot of bad things happened because of it.Here is what I think is a good example. Say yo have a SQL Server which has SQL authentication enabled, and the "sa" account gets compromised. With xp_cmdshell enabled (I'm not sure if the "sa" can enable that), you can now compromise the entire server, and potentially more. Without xp_cmdshell, the incident is limited to the SQL server.But also, i just opens up a can of worms. You have jobs that depend on it, maybe somebody granted some specific user the right to execute cmdshell, and so forth. Just like you said, as soon as you have a server with multiple admins, it gets tricky.IMHO it's better to run jobs through the Task Scheduler if they need to run commands in the OS, and then just add/update data in SQL from there if needed.I don't know when xp_cmdshell was introduced (might have been before SQL 2000), but it comes from a time when security was not taken as seriously as it is today.</description><pubDate>Thu, 24 Jun 2010 07:03:52 GMT</pubDate><dc:creator>WizardOfOz</dc:creator></item><item><title>RE: Using the UPTIME Utility to Monitor Servers</title><link>http://www.sqlservercentral.com/Forums/Topic941473-2723-1.aspx</link><description>Good point.I've never really understood the big fuss over xp_cmdshell being enabled or not.  I see how it can be a security risk, and how if SQL security gets compromised then access can be gained to the OS/domain (depending on the SQL Server service account) and limiting collateral damage through siloed access/responsibility but by default only sysadmins can run it.  If you control who has sysadmin access, it's not so much of an issue.Besides which, what is more of an issue - your sysadmin (or hacker) can run files on the OS or he has access to all the &amp;lt;insert sensitive data here&amp;gt;?Maybe it's because I've never had to deal with systems that are [i]so[/i] sensitive you need a minimum of 3 people to accomplish any given task on that system.</description><pubDate>Wed, 23 Jun 2010 20:56:59 GMT</pubDate><dc:creator>The CosmicTrickster</dc:creator></item><item><title>RE: Using the UPTIME Utility to Monitor Servers</title><link>http://www.sqlservercentral.com/Forums/Topic941473-2723-1.aspx</link><description>CosmicTrickster: That's a good point, and is probably acceptable for environments that don't require extremely high security. Still, one would want to make sure that the command being executed can't get stuck - e.g. take a long time to complete for whatever reason. Such a job should then probably be monitored to ensure the xp_cmdshell is disabled again - maybe even with a separate job that runs regardless and disable xp_cmdshell at a given time. One should also make sure that the file executed through xp_cmdshell can't be easily replaced with a rogue binary by an unauthorized user, but that would apply to any batch job really.If it's just about inserting some string into a table, then I wonder if it's not more efficient to just write a script that executes whichever utility, and then just adds the row to the table via OLEDB/ODBC/etc.</description><pubDate>Wed, 23 Jun 2010 20:03:50 GMT</pubDate><dc:creator>WizardOfOz</dc:creator></item><item><title>RE: Using the UPTIME Utility to Monitor Servers</title><link>http://www.sqlservercentral.com/Forums/Topic941473-2723-1.aspx</link><description>If you're running it as a SQL Agent job, why not enable xp_cmdshell on the first step, run the utility in the next step then disable xp_cmdshell in the last step.  I do that for one of my tasks that requires xp_cmdshell.  If it runs in seconds, any attack window is minimal.</description><pubDate>Wed, 23 Jun 2010 19:55:11 GMT</pubDate><dc:creator>The CosmicTrickster</dc:creator></item><item><title>RE: Using the UPTIME Utility to Monitor Servers</title><link>http://www.sqlservercentral.com/Forums/Topic941473-2723-1.aspx</link><description>WizardOfOz - thanksI only mentioned testing as each org is different.  We use Applocker in our environment  to lock down all .exes, .DLLs etc on production boxes so anyone who has a similar setup would need to go through the ropes of testing before approval.  Good to know though even if your .exe does not do remote uptime (as yet :)</description><pubDate>Wed, 23 Jun 2010 12:40:00 GMT</pubDate><dc:creator>lake_xp</dc:creator></item><item><title>RE: Using the UPTIME Utility to Monitor Servers</title><link>http://www.sqlservercentral.com/Forums/Topic941473-2723-1.aspx</link><description>Since someone mentioned using CLR to get this information I will say that my SQLCLR project, SQL# (SQLsharp), includes this function.  It is usable in SQL Server 2005 and 2008 and is the real system uptime, not the DB uptime.  It returns the number of milliseconds since the system was started.  This can be used to determine what the exact date &amp; time via:[code="sql"]SELECT DATEADD(MILLISECOND, (SQL#.OS_Uptime() * -1), GETDATE())[/code]I hope this helps.Take care,Solomon...</description><pubDate>Wed, 23 Jun 2010 11:48:41 GMT</pubDate><dc:creator>Solomon Rutzky</dc:creator></item><item><title>RE: Using the UPTIME Utility to Monitor Servers</title><link>http://www.sqlservercentral.com/Forums/Topic941473-2723-1.aspx</link><description>I do not agree to enable xp_cmdshell also no longer used in recent versions of SQL. Sorry.Itu.</description><pubDate>Wed, 23 Jun 2010 10:14:26 GMT</pubDate><dc:creator>Daniel Iturriaga</dc:creator></item><item><title>RE: Using the UPTIME Utility to Monitor Servers</title><link>http://www.sqlservercentral.com/Forums/Topic941473-2723-1.aspx</link><description>:-)Well, it's not really an install anyways, just a command-line app. But if you rather use Microsoft's outdated version that crashes - or enable xp_cmdshell then please go ahead ;-)I actually wrote that tool, and it just queries the uptime from a Windows performance counter - so it's pretty safe :-)</description><pubDate>Wed, 23 Jun 2010 08:24:23 GMT</pubDate><dc:creator>WizardOfOz</dc:creator></item><item><title>RE: Using the UPTIME Utility to Monitor Servers</title><link>http://www.sqlservercentral.com/Forums/Topic941473-2723-1.aspx</link><description>WizardOfOz - thanks However, i'm extremely wary of 3rd party .exes on our production boxes.  I'd strongly recommend testing this thoroughly in a test environment.  ...oh the irony of a utility to test uptime that brings your systems down :-)</description><pubDate>Wed, 23 Jun 2010 08:00:03 GMT</pubDate><dc:creator>lake_xp</dc:creator></item><item><title>RE: Using the UPTIME Utility to Monitor Servers</title><link>http://www.sqlservercentral.com/Forums/Topic941473-2723-1.aspx</link><description>lake_xp: Check out the NTToolkit [url]http://www.netikus.net/products_nttoolkit.html[/url], it also includes a "uptime.exe". For a simple display, just run "uptime /onetime". Unfortunately it doesn't run against remote machines (yet).</description><pubDate>Wed, 23 Jun 2010 07:10:39 GMT</pubDate><dc:creator>WizardOfOz</dc:creator></item><item><title>RE: Using the UPTIME Utility to Monitor Servers</title><link>http://www.sqlservercentral.com/Forums/Topic941473-2723-1.aspx</link><description>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 ([url]http://www.eventsentry.com[/url]) 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.</description><pubDate>Wed, 23 Jun 2010 07:05:35 GMT</pubDate><dc:creator>WizardOfOz</dc:creator></item><item><title>RE: Using the UPTIME Utility to Monitor Servers</title><link>http://www.sqlservercentral.com/Forums/Topic941473-2723-1.aspx</link><description>Good Article, uptime is sadly outdated and often crashes on Win2008</description><pubDate>Wed, 23 Jun 2010 07:02:47 GMT</pubDate><dc:creator>lake_xp</dc:creator></item><item><title>RE: Using the UPTIME Utility to Monitor Servers</title><link>http://www.sqlservercentral.com/Forums/Topic941473-2723-1.aspx</link><description>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_sql1440 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</description><pubDate>Wed, 23 Jun 2010 06:45:35 GMT</pubDate><dc:creator>S. Kusen</dc:creator></item><item><title>RE: Using the UPTIME Utility to Monitor Servers</title><link>http://www.sqlservercentral.com/Forums/Topic941473-2723-1.aspx</link><description>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.</description><pubDate>Wed, 23 Jun 2010 04:04:00 GMT</pubDate><dc:creator>philcart</dc:creator></item><item><title>RE: Using the UPTIME Utility to Monitor Servers</title><link>http://www.sqlservercentral.com/Forums/Topic941473-2723-1.aspx</link><description>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.</description><pubDate>Wed, 23 Jun 2010 03:14:39 GMT</pubDate><dc:creator>Josep</dc:creator></item><item><title>RE: Using the UPTIME Utility to Monitor Servers</title><link>http://www.sqlservercentral.com/Forums/Topic941473-2723-1.aspx</link><description>[quote]Secondly, that won't work for a server that you might want to monitor that doesn't actually have SQL Server installed on it! [/quote]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</description><pubDate>Wed, 23 Jun 2010 03:05:24 GMT</pubDate><dc:creator>Wilfred van Dijk</dc:creator></item><item><title>RE: Using the UPTIME Utility to Monitor Servers</title><link>http://www.sqlservercentral.com/Forums/Topic941473-2723-1.aspx</link><description>[quote][b]drikusvd (6/22/2010)[/b][hr]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.[/quote]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!</description><pubDate>Wed, 23 Jun 2010 01:06:21 GMT</pubDate><dc:creator>paul.knibbs</dc:creator></item><item><title>RE: Using the UPTIME Utility to Monitor Servers</title><link>http://www.sqlservercentral.com/Forums/Topic941473-2723-1.aspx</link><description>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</description><pubDate>Tue, 22 Jun 2010 22:35:32 GMT</pubDate><dc:creator>drikusvd</dc:creator></item><item><title>Using the UPTIME Utility to Monitor Servers</title><link>http://www.sqlservercentral.com/Forums/Topic941473-2723-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/articles/Monitoring/70349/"&gt;Using the UPTIME Utility to Monitor Servers&lt;/A&gt;[/B]</description><pubDate>Tue, 22 Jun 2010 21:48:52 GMT</pubDate><dc:creator>Richard F. Pless</dc:creator></item></channel></rss>