Created
September 3, 2018 02:00
-
-
Save smaglio81/0f61c60b665a0caf16abdc28adeb9d99 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE [IisLogs] | |
GO | |
/****** Object: StoredProcedure [dbo].[usp_Calculate_ProxySiteActiveConnections_For_Date] Script Date: 9/2/2018 6:59:59 PM ******/ | |
SET ANSI_NULLS ON | |
GO | |
SET QUOTED_IDENTIFIER ON | |
GO | |
ALTER procedure [dbo].[usp_Calculate_ProxySiteActiveConnections_For_Date] | |
@Date date | |
as | |
declare @dateStart varchar(10) = @Date, | |
@dateEnd varchar(10) = dateadd(d, 1, @Date), | |
@includeAll bit = 0, | |
@intervalInSeconds int = 1 | |
insert into dbo.ProxySiteActiveConnections | |
select [date], [time], [SiteName] | |
,sum([connections]) [total-connections] | |
,((sum([connections]) * 1.0) / 60) [connections-per-minute] | |
,convert(decimal(4,2), (((sum([connections]) * 1.0) / 60) / 3000.0)) [lcus] | |
from ( | |
select [date], [time], [SiteName], [type], count(*) [connections] | |
from ( | |
select convert(date, EntryTime) [date] | |
,format(datepart(hour, EntryTime), '0#') + ':00:00' [time] | |
,[SiteName] | |
,min(EntryTime) [Start] | |
,cIp | |
,'not services conns' [type] | |
,count(*) [cnt] | |
from dbo.IisLog | |
where ( | |
(EntryTime >= @dateStart and EntryTime < @dateEnd) | |
or @includeAll = 1 | |
) | |
and not ( | |
csUriStem like '/webservices/%' | |
or ( | |
SiteName in ('blue.sa.ucsb.edu', 'isis.sa.ucsb.edu') | |
and csUriStem like '/services/%' | |
) | |
) | |
group by convert(date, EntryTime), | |
datepart(hour, EntryTime), | |
[SiteName], | |
datepart(minute, EntryTime), | |
datepart(second, EntryTime) / @intervalInSeconds, | |
cIp | |
) f | |
group by [date], [time], [SiteName], [type] | |
union | |
select convert(date, EntryTime) [date] | |
,format(datepart(hour, EntryTime), '0#') + ':00:00' [time] | |
,[SiteName] | |
,'services conns' [type] | |
,count(*) [connections] | |
from dbo.IisLog | |
where ( | |
(EntryTime >= @dateStart and EntryTime < @dateEnd) | |
or @includeAll = 1 | |
) | |
and ( | |
csUriStem like '/webservices/%' | |
or ( | |
SiteName in ('blue.sa.ucsb.edu', 'isis.sa.ucsb.edu') | |
and csUriStem like '/services/%' | |
) | |
) | |
group by convert(date, EntryTime), | |
datepart(hour, EntryTime), | |
[SiteName] | |
) d | |
group by [date], [time], SiteName; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment