home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
moodle.waes.ac.uk
/
moodle.waes.ac.uk.zip
/
moodle.waes.ac.uk
/
TMG
/
SP1-TMG-KB981324-AMD64-ENU.msp
/
PCW_CAB_SHFx2
/
F2143_msfpcui.dll
/
BINARY
/
25578
< prev
next >
Wrap
Text File
|
2010-06-15
|
3KB
|
88 lines
CREATE PROCEDURE [dbo].[ISA_spIpsTopIntrusionsRDL]
@FromDate datetime,
@ToDate datetime,
@ReportType varchar(10),
@TopCount int
AS
BEGIN
DECLARE @SummTableName varchar(100)
SET @SummTableName = dbo.fnGetSummaryTableName('tblIpsSummary', @FromDate, @ToDate, @ReportType)
CREATE TABLE #Table1
(
[SignatureName] nvarchar(4000),
[Incidents] bigint,
[BlockedIncidents] bigint,
[AllowedIncidents] bigint
)
IF OBJECT_ID (@SummTableName, 'u') IS NOT NULL
BEGIN
DECLARE @strQuery varchar(8000)
SET @strQuery =
'SELECT
[SignatureName],
SUM([Incidents]) AS [Incidents],
CASE
WHEN ([Action] = 2) Then SUM([Incidents])
ELSE 0
END AS BlockedIncidents,
CASE
WHEN ([Action] = 3) Then SUM([Incidents])
ELSE 0
END AS AllowedIncidents
FROM ' + @SummTableName + '
WHERE
([Date] >= ' + QUOTENAME(CONVERT(varchar, @FromDate, 126),CHAR(39)) + ' AND [Date] <= ' + QUOTENAME(CONVERT(varchar, @ToDate, 126),CHAR(39)) + ')
GROUP BY
[SignatureName],
[Action]
'
INSERT #Table1
EXEC(@strQuery)
END
CREATE TABLE #Table2
(
[SignatureName] nvarchar(4000),
[Incidents] bigint,
[BlockedIncidents] bigint,
[AllowedIncidents] bigint
)
INSERT INTO #Table2
SELECT
[SignatureName] AS [SignatureName],
SUM([Incidents]) AS [Incidents],
SUM([BlockedIncidents]) AS [BlockedIncidents],
SUM([AllowedIncidents]) AS [AllowedIncidents]
FROM #Table1
WHERE ([Incidents] > 0)
GROUP BY [SignatureName]
ORDER BY SUM([Incidents]) DESC
DECLARE @TotalIncidents bigint
SET @TotalIncidents = (SELECT SUM([Incidents]) FROM #Table2)
IF (@TotalIncidents = 0)
SET @TotalIncidents = 1
SELECT TOP(@TopCount)
o.[SignatureName] AS [SignatureName],
oo.[SignatureDescription] AS [SignatureDescription],
o.[Incidents] AS [Incidents],
(CAST(o.[Incidents] AS decimal) / @TotalIncidents) AS [IncidentRatio],
o.[BlockedIncidents] AS [BlockedIncidents],
o.[AllowedIncidents] AS [AllowedIncidents]
FROM #Table2 AS o
LEFT JOIN [tblIpsMetadata] AS oo
ON o.[SignatureName] = oo.[SignatureName]
UNION ALL
SELECT
N'{[23124]}' As [SignatureName],
N' ' As [SignatureDescription],
SUM([Incidents]) AS [Incidents],
(CAST(SUM([Incidents]) AS decimal) / @TotalIncidents) AS [IncidentRatio],
SUM([BlockedIncidents]) AS [BlockedIncidents],
SUM([AllowedIncidents]) AS [AllowedIncidents]
FROM #Table2 t1
WHERE NOT EXISTS
(SELECT * FROM
(SELECT TOP(@TopCount) *
FROM #Table2) t2
WHERE t1.[SignatureName] = t2.[SignatureName])
END