made query more performance and allowed embedded override
This commit is contained in:
parent
494edd98ee
commit
42880bb334
@ -23,41 +23,19 @@ client_id = "eft-event-generator-confidential"
|
||||
secret = ""
|
||||
|
||||
[database]
|
||||
overrideEmbeddedquery = false
|
||||
driver = "ODBC Driver 18 for SQL Server"
|
||||
server = "192.168.x.x"
|
||||
database = "EFTDB"
|
||||
user = "a"
|
||||
password = "a"
|
||||
query = """DECLARE @stopTime DATETIME2
|
||||
SET @stopTime = DATEADD(DAY, -30, GETDATE())
|
||||
SELECT p.[ProtocolCommandID]
|
||||
,t.[Time_stamp]
|
||||
,p.[RemoteIP]
|
||||
,p.[RemotePort]
|
||||
,p.[LocalIP]
|
||||
,p.[LocalPort]
|
||||
,p.[Protocol]
|
||||
,p.[SiteName]
|
||||
,p.[Command]
|
||||
,p.[CommandParameters]
|
||||
,p.[FileName]
|
||||
,p.[VirtualFolderName]
|
||||
,p.[PhysicalFolderName]
|
||||
,p.[IsInternal]
|
||||
,p.[FileSize]
|
||||
,p.[TransferTime]
|
||||
,p.[BytesTransferred]
|
||||
,p.[ResultID]
|
||||
,t.[TransactionID]
|
||||
,p.[Description]
|
||||
,p.[Actor]
|
||||
,t.ParentTransactionID
|
||||
,t.TransactionObject
|
||||
,t.NodeName
|
||||
,t.TransactionGUID
|
||||
,a.Protocol user_type
|
||||
FROM [EFTDB].[dbo].[tbl_Transactions] t Full JOIN tbl_ProtocolCommands p ON (t.TransactionID = p.TransactionID) Full join tbl_Authentications a ON (t.TransactionID = a.TransactionID)
|
||||
WHERE p.Time_stamp > @stopTime"""
|
||||
query = """DECLARE @stopTime DATETIME2
|
||||
SET @stopTime=DATEADD(DAY, -30, GETDATE())
|
||||
SELECT p.ProtocolCommandID, t.Time_stamp, p.RemoteIP, p.RemotePort, p.LocalIP, p.LocalPort, p.Protocol, p.SiteName, p.Command, p.FileName, p.VirtualFolderName, p.FileSize, p.TransferTime, p.BytesTransferred, p.Description, p.ResultID, t.TransactionID, p.Actor, t.TransactionObject, t.NodeName, t.TransactionGUID, a.Protocol user_type
|
||||
FROM tbl_Transactions t
|
||||
Full JOIN tbl_ProtocolCommands p ON(t.TransactionID=p.TransactionID)
|
||||
Full JOIN tbl_Authentications a ON(t.TransactionID=a.TransactionID)
|
||||
WHERE p.Time_stamp>@stopTime AND p.Command IS NOT NULL"""
|
||||
|
||||
[immutables]
|
||||
prd_instance_id = 1
|
||||
|
5
inex.py
5
inex.py
@ -48,6 +48,7 @@ class Inex:
|
||||
self.selectedPlatform = self.config["fortraPlatform"]["selectedPlatform"]
|
||||
self.writeJsonfile = self.config["output"]["dumpTojson"]
|
||||
self.pushToplatform = self.config["output"]["pushToplatform"]
|
||||
self.queryOverride = self.config["database"]["overrideEmbeddedquery"]
|
||||
|
||||
if "dev" in self.selectedPlatform.lower():
|
||||
self.platformConfig = self.config["fortraPlatform"]["dev"]
|
||||
@ -55,7 +56,6 @@ class Inex:
|
||||
self.platformConfig = self.config["fortraPlatform"]["stage"]
|
||||
if "prod" in self.selectedPlatform.lower():
|
||||
self.platformConfig = self.config["fortraPlatform"]["prod"]
|
||||
# print(self.platformConfig)
|
||||
|
||||
#Setup logging
|
||||
inexLog(self)
|
||||
@ -63,9 +63,8 @@ class Inex:
|
||||
# create the connection to the database
|
||||
self.cursor = self.ic.inexSql.connectDatabase(self, self.db, self.dbDriver, self.dbServer, self.dbDatabase, self.dbUser, self.dbPassword)
|
||||
|
||||
# self.data = self.ic.inexSql.databaseQuery(self, self.cursor, self.dbQuery)
|
||||
|
||||
self.data = self.ic.inexSql.databaseQuery(self, self.cursor, self.sq.sqlQuerymodel.queryData())
|
||||
self.data = self.ic.inexSql.databaseQuery(self, self.cursor, self.sq.sqlQuerymodel.queryData(self.queryOverride,self.dbQuery))
|
||||
|
||||
self.modifiedData = processData(self.data, dataTemplate, prd_instance_id=self.prdInstanceID,\
|
||||
product_guid=self.productGUID,product_name=self.productName,product_version=self.productVersion)
|
||||
|
@ -35,7 +35,7 @@ def dataTemplate(transactionType,**kwargs):
|
||||
"tenant_name":"GlobalScape",
|
||||
"time": kwargs.get('time'),
|
||||
"status_code": kwargs.get('status_code'),
|
||||
"status_detail": kwargs.get('status_detail'),
|
||||
"status_detail": kwargs.get('description'),
|
||||
"user": {
|
||||
"home_directory": kwargs.get('user_home_directory'),
|
||||
"uuid": kwargs.get('guid'),
|
||||
|
@ -36,6 +36,7 @@ def processData(data, template, **kwargs):
|
||||
user_domain=row.get('SiteName'),\
|
||||
user_name=row.get('Actor'),\
|
||||
user_home_directory=row.get('VirtualFolderName'),\
|
||||
description=row.get('Description'),\
|
||||
utype=identifyUtype(row.get('Command'))))
|
||||
|
||||
if row.get('TransactionGUID') not in transactionLoginid:
|
||||
|
@ -1,11 +1,11 @@
|
||||
class sqlQuerymodel:
|
||||
def queryData():
|
||||
def queryData(overRideflag, configQuery):
|
||||
"""Embedded query data"""
|
||||
q ="""DECLARE @stopTime DATETIME2
|
||||
SET @stopTime=DATEADD(DAY, -30, GETDATE())
|
||||
SELECT p.ProtocolCommandID, t.Time_stamp, p.RemoteIP, p.RemotePort, p.LocalIP, p.LocalPort, p.Protocol, p.SiteName, p.Command, p.CommandParameters, p.FileName, p.VirtualFolderName, p.PhysicalFolderName, p.IsInternal, p.FileSize, p.TransferTime, p.BytesTransferred, p.ResultID, t.TransactionID, p.Description, p.Actor, t.ParentTransactionID, t.TransactionObject, t.NodeName, t.TransactionGUID, a.Protocol user_type
|
||||
SELECT p.ProtocolCommandID, t.Time_stamp, p.RemoteIP, p.RemotePort, p.LocalIP, p.LocalPort, p.Protocol, p.SiteName, p.Command, p.FileName, p.VirtualFolderName, p.FileSize, p.TransferTime, p.BytesTransferred, p.Description, p.ResultID, t.TransactionID, p.Actor, t.TransactionObject, t.NodeName, t.TransactionGUID, a.Protocol user_type
|
||||
FROM tbl_Transactions t
|
||||
Full JOIN tbl_ProtocolCommands p ON(t.TransactionID=p.TransactionID)
|
||||
Full join tbl_Authentications a ON(t.TransactionID=a.TransactionID)
|
||||
WHERE p.Time_stamp>@stopTime"""
|
||||
return q
|
||||
WHERE p.Time_stamp>@stopTime AND p.Command IS NOT NULL"""
|
||||
return configQuery if overRideflag else q
|
Loading…
x
Reference in New Issue
Block a user