Uptime Util
Nov 1, 2002anyone know where to find the uptime utility for the commandline. This gives you the server's uptime in days. Thanks for your help.
View 3 Repliesanyone know where to find the uptime utility for the commandline. This gives you the server's uptime in days. Thanks for your help.
View 3 RepliesI'm trying to use the rcmd utility and when i try to connect to a server with it i get this error...
system not found or service not active? How do you activate the rcmd service? thanks for your help.
There is support in Osql util in SqlServer 2005 ?
View 1 Replies View RelatedTo view the system uptime.
The @noprocs variable needs to be set to the number of processors the server has.
Also the convert function has to have the correct mask for the regional settings of the os.
I suggest you just run
"net statistics server" from the command prompt and see what the time format is for the server.
(103 is for British/French setting)
CREATE procedure dba_uptime as
set nocount on
create table #output(outp nvarchar(1000))
insert #output(outp)
exec master.dbo.xp_cmdshell N'net statistics server'
declare @upsince datetime, @sqlupsince datetime, @noprocs int
set @noprocs = 8
set @upsince =
(
selectconvert(datetime,replace(outp,'Statistics since ',''),103) as system_up_since
from#output
whereoutp like('Statistics since %')
)
drop table #output
set @sqlupsince =
(
selectdateadd(s,-(32.0/@noprocs)*(cast(@@idle as float)+@@cpu_busy+@@io_busy)/1000.0,getdate())
)
select@upsince as systemUpSince
,@sqlupsince as sqlServerUpSince
go
exec dba_uptime
/*
systemUpSince sqlServerUpSince
----------------------- -----------------------
2006-02-19 03:23:00.000 2006-03-29 08:35:26.803
*/
rockmoose
Edit: fixed convert to int overflow, should work for appx 68yrs uptime now.
Here is a brief description what I am actually looking at. As we all have SLA's to understand how much uptime/downtime we can afford maybe per year/per quarter. I am keenly interested in finding out the way of calculating the sql server uptime. I googled for this and didn't find an appropriate solution that can justify my needs.
I am looking at a way that can give me a historical view of the uptime (possibly aggregated over time), considering all the facts for e.g I am not considering the maintenance that we do for keeping our servers up to date which includes patching and stuff, instead I am more focused on the historical view that for e.g if my manager asks me to give him a report stating the uptime for all the sql servers that we have for the current quarter.
Hence, I would basically some kind of script wherein I am storing the history somewhere and at a later date if my manager asks me to give a quarterly uptime report I can pull out that aggregated data, and generate a pie chart or something from that data to show the uptime and downtime for the same. I don't want to use 3rd party tool and I know there are quite a few, but company won't afford it.
Hi friends,
I need a query to find out the server uptime and downtime of the server from MOM database, i don't know in which tables MOM actually stores this infomation.
I need this very urgently.
Thanks in advance
You can use this code to find out the information stored in the MOM tables:-
############################################################################
create PROC [dbo].[SearchMyTables]
(
@SearchStr nvarchar(100)
)
AS
BEGIN
CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630))
SET NOCOUNT ON
DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110)
SET @TableName = ''
SET @SearchStr2 = QUOTENAME('%' + @SearchStr + '%','''')
WHILE @TableName IS NOT NULL
BEGIN
SET @ColumnName = ''
SET @TableName =
(
SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME))
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
AND QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @TableName
AND OBJECTPROPERTY(
OBJECT_ID(
QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)
), 'IsMSShipped'
) = 0
)
WHILE (@TableName IS NOT NULL) AND (@ColumnName IS NOT NULL)
BEGIN
SET @ColumnName =
(
SELECT MIN(QUOTENAME(COLUMN_NAME))
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = PARSENAME(@TableName, 2)
AND TABLE_NAME = PARSENAME(@TableName, 1)
AND DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar')
AND QUOTENAME(COLUMN_NAME) > @ColumnName
)
IF @ColumnName IS NOT NULL
BEGIN
INSERT INTO #Results
EXEC
(
'SELECT ''' + @TableName + '.' + @ColumnName + ''', LEFT(' + @ColumnName + ', 3630)
FROM ' + @TableName + ' (NOLOCK) ' +
' WHERE ' + @ColumnName + ' LIKE ' + @SearchStr2
)
END
END
END
SELECT ColumnName, ColumnValue FROM #Results
END############################################################################