Skip to content

Commit

Permalink
Traffic analyzer standalone entry (#848)
Browse files Browse the repository at this point in the history
  • Loading branch information
pomodorox authored Apr 28, 2021
1 parent 2f6d23a commit afde9ef
Show file tree
Hide file tree
Showing 11 changed files with 304 additions and 79 deletions.
10 changes: 8 additions & 2 deletions daq/acl_state_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ def _get_port_rule_counts(self, switch, port, acl_config, rule_samples):
acl_config._id, rule_config.get('description'))
continue

rule_description = rule_config.get('description')
if not rule_description:
LOGGER.error('Rule with cookie %s does not have a description', cookie_num)
continue

has_sample = False
for sample in rule_samples:
if str(sample.labels.get('cookie')) != str(cookie_num):
Expand All @@ -49,14 +54,15 @@ def _get_port_rule_counts(self, switch, port, acl_config, rule_samples):
continue
if int(sample.labels.get('in_port')) != port:
continue
rule_map = rules_map.setdefault(rule_config['description'], {})

rule_map = rules_map.setdefault(rule_description, {})
rule_map['packet_count'] = int(sample.value)
has_sample = True
break

if not has_sample:
error = (f'No ACL metric sample available for switch, port, ACL, rule: '
f'{switch}, {port}, {acl_config._id}, {rule_config["description"]} '
f'{switch}, {port}, {acl_config._id}, {rule_description} '
f'(cookie={cookie_num})')
errors.append(error)
LOGGER.error(error)
Expand Down
9 changes: 1 addition & 8 deletions daq/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,6 @@ def _stripped_alt_logger(self, level, msg, *args, **kwargs):
ALT_LOG._log(level, stripped, *args, **kwargs)


def _write_pid_file():
pid = os.getpid()
LOGGER.info('pid is %d', pid)
with open(_PID_FILE, 'w') as pid_file:
pid_file.write(str(pid))


def _execute():
daq = DAQ(sys.argv)
configurator.print_config(daq.config)
Expand All @@ -120,7 +113,7 @@ def _execute():
if not daq.validate_config():
return 1

_write_pid_file()
utils.write_pid_file(_PID_FILE, LOGGER)

signal.signal(signal.SIGINT, signal.default_int_handler)
signal.signal(signal.SIGTERM, signal.default_int_handler)
Expand Down
75 changes: 41 additions & 34 deletions daq/proto/acl_counting_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit afde9ef

Please sign in to comment.