Loading src/l3_distributedattackdetector/service/l3_distributedattackdetector.py +10 −7 Original line number Original line Diff line number Diff line Loading @@ -81,9 +81,9 @@ class l3_distributedattackdetector: with grpc.insecure_channel(CENTRALIZED_ATTACK_DETECTOR) as channel: with grpc.insecure_channel(CENTRALIZED_ATTACK_DETECTOR) as channel: self.cad = L3CentralizedattackdetectorStub(channel) self.cad = L3CentralizedattackdetectorStub(channel) LOGGER.info("Connected to the centralized attack detector") LOGGER.info("Connected to the Centralized Attack Detector") LOGGER.info("Obtaining features...") LOGGER.info("Obtaining features Ids. from the Centralized Attack Detector...") self.feature_ids = self.get_features_ids() self.feature_ids = self.get_features_ids() LOGGER.info("Features Ids.: {:s}".format(str(self.feature_ids))) LOGGER.info("Features Ids.: {:s}".format(str(self.feature_ids))) Loading Loading @@ -118,10 +118,10 @@ class l3_distributedattackdetector: # start an infinite loop # start an infinite loop while True: while True: # read last line of file # read last line of the file line = file.readline() line = file.readline() # sleep if file hasn't been updated # sleep if the file hasn't been updated if not line: if not line: time.sleep(time_sleep) time.sleep(time_sleep) continue continue Loading @@ -135,16 +135,19 @@ class l3_distributedattackdetector: yield line yield line def load_file(self, dirname=TSTAT_DIR_NAME): # - Client side - def load_file(self, dirname=TSTAT_DIR_NAME): while True: while True: here = os.path.dirname(os.path.abspath(__file__)) here = os.path.dirname(os.path.abspath(__file__)) tstat_piped = os.path.join(here, dirname) tstat_piped = os.path.join(here, dirname) tstat_dirs = os.listdir(tstat_piped) tstat_dirs = os.listdir(tstat_piped) if len(tstat_dirs) > 0: if len(tstat_dirs) > 0: tstat_dirs.sort() tstat_dirs.sort() new_dir = tstat_dirs[-1] new_dir = tstat_dirs[-1] tstat_file = tstat_piped + new_dir + "/log_tcp_temp_complete" tstat_file = tstat_piped + new_dir + "/log_tcp_temp_complete" LOGGER.info("Following: {:s}".format(str(tstat_file))) LOGGER.info("Following: {:s}".format(str(tstat_file))) return tstat_file return tstat_file else: else: LOGGER.info("No Tstat directory!") LOGGER.info("No Tstat directory!") Loading @@ -165,7 +168,7 @@ class l3_distributedattackdetector: feature = feature_id - 1 feature = feature_id - 1 values.append(float(line[feature])) values.append(float(line[feature])) except IndexError: except IndexError: print("IndexError: {0}".format(line)) LOGGER.error("IndexError: {0}".format(line)) return values return values Loading Loading
src/l3_distributedattackdetector/service/l3_distributedattackdetector.py +10 −7 Original line number Original line Diff line number Diff line Loading @@ -81,9 +81,9 @@ class l3_distributedattackdetector: with grpc.insecure_channel(CENTRALIZED_ATTACK_DETECTOR) as channel: with grpc.insecure_channel(CENTRALIZED_ATTACK_DETECTOR) as channel: self.cad = L3CentralizedattackdetectorStub(channel) self.cad = L3CentralizedattackdetectorStub(channel) LOGGER.info("Connected to the centralized attack detector") LOGGER.info("Connected to the Centralized Attack Detector") LOGGER.info("Obtaining features...") LOGGER.info("Obtaining features Ids. from the Centralized Attack Detector...") self.feature_ids = self.get_features_ids() self.feature_ids = self.get_features_ids() LOGGER.info("Features Ids.: {:s}".format(str(self.feature_ids))) LOGGER.info("Features Ids.: {:s}".format(str(self.feature_ids))) Loading Loading @@ -118,10 +118,10 @@ class l3_distributedattackdetector: # start an infinite loop # start an infinite loop while True: while True: # read last line of file # read last line of the file line = file.readline() line = file.readline() # sleep if file hasn't been updated # sleep if the file hasn't been updated if not line: if not line: time.sleep(time_sleep) time.sleep(time_sleep) continue continue Loading @@ -135,16 +135,19 @@ class l3_distributedattackdetector: yield line yield line def load_file(self, dirname=TSTAT_DIR_NAME): # - Client side - def load_file(self, dirname=TSTAT_DIR_NAME): while True: while True: here = os.path.dirname(os.path.abspath(__file__)) here = os.path.dirname(os.path.abspath(__file__)) tstat_piped = os.path.join(here, dirname) tstat_piped = os.path.join(here, dirname) tstat_dirs = os.listdir(tstat_piped) tstat_dirs = os.listdir(tstat_piped) if len(tstat_dirs) > 0: if len(tstat_dirs) > 0: tstat_dirs.sort() tstat_dirs.sort() new_dir = tstat_dirs[-1] new_dir = tstat_dirs[-1] tstat_file = tstat_piped + new_dir + "/log_tcp_temp_complete" tstat_file = tstat_piped + new_dir + "/log_tcp_temp_complete" LOGGER.info("Following: {:s}".format(str(tstat_file))) LOGGER.info("Following: {:s}".format(str(tstat_file))) return tstat_file return tstat_file else: else: LOGGER.info("No Tstat directory!") LOGGER.info("No Tstat directory!") Loading @@ -165,7 +168,7 @@ class l3_distributedattackdetector: feature = feature_id - 1 feature = feature_id - 1 values.append(float(line[feature])) values.append(float(line[feature])) except IndexError: except IndexError: print("IndexError: {0}".format(line)) LOGGER.error("IndexError: {0}".format(line)) return values return values Loading