-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.py
38 lines (32 loc) · 1.63 KB
/
Main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from ConnectElastic import ConnectElastic
from Manager import Manager
from Ultility import Ultility
from Configuration import Configuration
configData = Configuration()
#Get data from config file
elasticBeginTimesstamp = configData.beginTimestamp
currentTimestamp = Ultility.get_current_time()
while not Ultility.is_after_end_date(elasticBeginTimesstamp,currentTimestamp):
#Create Objects
manager = Manager()
#Connect to Elastic Search
esConnect = ConnectElastic(host=configData.host,port=configData.port,indexName=configData.indexName,beginTimestamp=elasticBeginTimesstamp,endTimesstamp = Ultility.plus_time(configData.timeRange,elasticBeginTimesstamp),
regexIndexName=configData.regexIndexName,trafficIndexName=configData.trafficIndexName)
#Update timestamp
elasticBeginTimesstamp = Ultility.plus_time(10,elasticBeginTimesstamp)
#Get query records
queryRecords = esConnect.get_DNS_Records()
print(len(queryRecords))
#Check if there is any records
if len(queryRecords) > 1:
#Traffic Analysis
trafficReports = manager.traffic_analysis(queryRecords=queryRecords)
#Send back to Elastic
manager.convert_to_JSON_send_elasticsearch(reports=trafficReports,elsaticConnection=esConnect,isTrafficAnalysis=True)
#Regex Analysis
regexReports = manager.regex_analysis(queryRecords=queryRecords)
#Send back to Elastic
#manager.convert_to_JSON_send_elasticsearch(reports=regexReports,elsaticConnection=esConnect,isTrafficAnalysis=False)
#Update config file
configData.beginTimestamp = currentTimestamp
configData.parse_JSON_config()