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