Updated query and mapped the proper data to the template
All checks were successful
Build Inex Executable / linux (push) Successful in 1m20s
All checks were successful
Build Inex Executable / linux (push) Successful in 1m20s
This commit is contained in:
parent
e421b1b376
commit
702d93b9da
@ -3,7 +3,7 @@ run-name: Deploy to ${{ inputs.deploy_target }} by @${{ gitea.actor }}
|
|||||||
on: [push]
|
on: [push]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
Build:
|
linux:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
@ -4,7 +4,41 @@ server = "192.168.x.x"
|
|||||||
database = "EFTDB"
|
database = "EFTDB"
|
||||||
user = "a"
|
user = "a"
|
||||||
password = "a"
|
password = "a"
|
||||||
query = "SELECT [Id],[Version] FROM [EFTDB].[dbo].[tbl_Schema_Version]"
|
query = """DECLARE @stopTime DATETIME2
|
||||||
|
SET @stopTime = DATEADD(DAY, -30, GETDATE())
|
||||||
|
SELECT [ProtocolCommandID]
|
||||||
|
,p.[Time_stamp]
|
||||||
|
,[RemoteIP]
|
||||||
|
,[RemotePort]
|
||||||
|
,[LocalIP]
|
||||||
|
,[LocalPort]
|
||||||
|
,[Protocol]
|
||||||
|
,[SiteName]
|
||||||
|
,[Command]
|
||||||
|
,[CommandParameters]
|
||||||
|
,[FileName]
|
||||||
|
,[VirtualFolderName]
|
||||||
|
,[PhysicalFolderName]
|
||||||
|
,[IsInternal]
|
||||||
|
,[FileSize]
|
||||||
|
,[TransferTime]
|
||||||
|
,[BytesTransferred]
|
||||||
|
,[ResultID]
|
||||||
|
,p.[TransactionID]
|
||||||
|
,[Description]
|
||||||
|
,[Actor]
|
||||||
|
,t.ParentTransactionID
|
||||||
|
,t.TransactionObject
|
||||||
|
,t.NodeName
|
||||||
|
,t.TransactionGUID
|
||||||
|
FROM [EFTDB].[dbo].[tbl_ProtocolCommands] p Full JOIN tbl_Transactions t ON (p.TransactionID = t.TransactionID)
|
||||||
|
WHERE p.Time_stamp > @stopTime"""
|
||||||
|
|
||||||
|
[immutables]
|
||||||
|
prd_instance_id = 1
|
||||||
|
product_guid = "asdf"
|
||||||
|
product_name = "EFT"
|
||||||
|
product_version ="8.1.0.9"
|
||||||
|
|
||||||
[output]
|
[output]
|
||||||
filename ="./data.json"
|
filename ="./data.json"
|
||||||
|
@ -4,8 +4,28 @@ server = "192.168.x.x"
|
|||||||
database = "EFTDB"
|
database = "EFTDB"
|
||||||
user = "a"
|
user = "a"
|
||||||
password = "a"
|
password = "a"
|
||||||
query = "SELECT [Id],[Version] FROM [EFTDB].[dbo].[tbl_Schema_Version]"
|
query = """SELECT TOP (1) [ProtocolCommandID]
|
||||||
|
,[Time_stamp]
|
||||||
|
,[RemoteIP]
|
||||||
|
,[RemotePort]
|
||||||
|
,[LocalIP]
|
||||||
|
,[LocalPort]
|
||||||
|
,[Protocol]
|
||||||
|
,[SiteName]
|
||||||
|
,[Command]
|
||||||
|
,[CommandParameters]
|
||||||
|
,[FileName]
|
||||||
|
,[VirtualFolderName]
|
||||||
|
,[PhysicalFolderName]
|
||||||
|
,[IsInternal]
|
||||||
|
,[FileSize]
|
||||||
|
,[TransferTime]
|
||||||
|
,[BytesTransferred]
|
||||||
|
,[ResultID]
|
||||||
|
,[TransactionID]
|
||||||
|
,[Description]
|
||||||
|
,[Actor]
|
||||||
|
FROM [EFTDB].[dbo].[tbl_ProtocolCommands]"""
|
||||||
[output]
|
[output]
|
||||||
filename ="./data.json"
|
filename ="./data.json"
|
||||||
|
|
||||||
|
10
inex.py
10
inex.py
@ -35,6 +35,10 @@ class Inex:
|
|||||||
self.useLog = self.config["logging"]["useLog"]
|
self.useLog = self.config["logging"]["useLog"]
|
||||||
self.logPath = self.config["logging"]["logPath"]
|
self.logPath = self.config["logging"]["logPath"]
|
||||||
self.logLevel = self.config["logging"]["logLevel"]
|
self.logLevel = self.config["logging"]["logLevel"]
|
||||||
|
self.prdInstanceID = self.config["immutables"]["prd_instance_id"]
|
||||||
|
self.productGUID = self.config["immutables"]["product_guid"]
|
||||||
|
self.productName = self.config["immutables"]["product_name"]
|
||||||
|
self.productVersion = self.config["immutables"]["product_version"]
|
||||||
|
|
||||||
#Setup logging
|
#Setup logging
|
||||||
inexLog(self)
|
inexLog(self)
|
||||||
@ -43,10 +47,10 @@ class Inex:
|
|||||||
self.cursor = self.ic.connectDatabase(self, self.db, self.dbDriver, self.dbServer, self.dbDatabase, self.dbUser, self.dbPassword)
|
self.cursor = self.ic.connectDatabase(self, self.db, self.dbDriver, self.dbServer, self.dbDatabase, self.dbUser, self.dbPassword)
|
||||||
|
|
||||||
self.data = self.ic.databaseQuery(self, self.cursor, self.dbQuery)
|
self.data = self.ic.databaseQuery(self, self.cursor, self.dbQuery)
|
||||||
# print(f"returned data: {self.data}")
|
|
||||||
self.modifiedData = processData(self.data, dataTemplate)
|
|
||||||
|
|
||||||
print(self.modifiedData)
|
self.modifiedData = processData(self.data, dataTemplate, prd_instance_id=self.prdInstanceID,\
|
||||||
|
product_guid=self.productGUID,product_name=self.productName,product_version=self.productVersion)
|
||||||
|
|
||||||
|
|
||||||
# TODO: move this to its own function
|
# TODO: move this to its own function
|
||||||
if self.useLog:
|
if self.useLog:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
def processData(data, template):
|
def processData(data, template, **kwargs):
|
||||||
processedData = []
|
processedData = []
|
||||||
for row in data:
|
for row in data:
|
||||||
# print(f'Row: {row}')
|
# print(f'Row: {row}')
|
||||||
@ -11,10 +11,10 @@ def processData(data, template):
|
|||||||
file_name=row.get('FileName'),\
|
file_name=row.get('FileName'),\
|
||||||
guid=row.get('TransactionGUID'),\
|
guid=row.get('TransactionGUID'),\
|
||||||
ref_id=row.get('ProtocolCommandID'),\
|
ref_id=row.get('ProtocolCommandID'),\
|
||||||
prd_instance_id=row.get(''),\
|
prd_instance_id=kwargs.get('prd_instance_id'),\
|
||||||
product_guid=row.get(''),\
|
product_guid=kwargs.get('product_guid'),\
|
||||||
product_name=row.get(''),\
|
product_name=kwargs.get('product_name'),\
|
||||||
product_version=row.get(''),\
|
product_version=kwargs.get('product_version'),\
|
||||||
node_name=row.get('NodeName'),\
|
node_name=row.get('NodeName'),\
|
||||||
src_endpoint_port=row.get('RemotePort'),\
|
src_endpoint_port=row.get('RemotePort'),\
|
||||||
src_endpoint_ip=row.get('RemoteIP'),\
|
src_endpoint_ip=row.get('RemoteIP'),\
|
||||||
@ -25,8 +25,17 @@ def processData(data, template):
|
|||||||
bytes_out=row.get('BytesTransferred'),\
|
bytes_out=row.get('BytesTransferred'),\
|
||||||
transfer_time=row.get('TransferTime'),\
|
transfer_time=row.get('TransferTime'),\
|
||||||
time=row.get('Time_stamp'),\
|
time=row.get('Time_stamp'),\
|
||||||
user_type=row.get(''),\
|
user_type=identifyUserType(row.get('user_type')),\
|
||||||
user_domain=row.get('SiteName'),\
|
user_domain=row.get('SiteName'),\
|
||||||
user_name=row.get('Actor'),\
|
user_name=row.get('Actor'),\
|
||||||
utype=row.get('Command')))
|
utype=row.get('TransactionObject')))
|
||||||
return processedData
|
return processedData
|
||||||
|
|
||||||
|
def identifyUserType(obj):
|
||||||
|
if obj:
|
||||||
|
if "Admin" in obj:
|
||||||
|
return "Administrator"
|
||||||
|
else:
|
||||||
|
return "User"
|
||||||
|
else:
|
||||||
|
return None
|
Loading…
x
Reference in New Issue
Block a user