« first day  last day (15 days later) » 

7:11 AM
Thank you. Just so you know it, I have really learned a lot by your examples and comments in combination with trying around a little. I will try to go trough all your comments and reply back. Have a nice day :o)
 
7:43 AM
Hmm I actually get a:
Traceback (most recent call last):
File "asa_log_sort_unique_denies_new.py", line 71, in <module>
print_counter(denial_counter)
File "asa_log_sort_unique_denies_new.py", line 60, in print_counter
print(LINE_FORMAT.format(protocol.lower(), src, dst, dst_port, count))
UnboundLocalError: local variable 'protocol' referenced before assignment
but isn't the protocol variable assigned in the regex statements?
Ahh, could it be, that the re_match_length isn't either 4 or 8 and hence the protocol, src, dst etc. is never "initialized"? For debugging purpose I entered print re_match in the for loop and I received this input:
File: test2.txt
prot source destination port hitcnt
------ ------------------ ------------------ ------ ------------------
('tcp', '1111:2222:3:4444::55', '1111:2222:3:4444::66', '/389 ', '/389 ', '389')
Traceback (most recent call last):
File "asa_log_sort_unique_denies_new.py", line 72, in <module>
print_counter(denial_counter)
File "asa_log_sort_unique_denies_new.py", line 61, in print_counter
print(LINE_FORMAT.format(protocol.lower(), src, dst, dst_port, count))
It appears that the first re_match is 6 and that is why I get a Traceback since protocol isn't "known". Hmm, I will try to test this a little....
 
 
2 hours later…
9:49 AM
Had to make a couple of more
if re_match_length == 8:
protocol, src, src_port, dst, dst_port, _, _, _ = re_match

if re_match_length == 4:
protocol, src, dst, dst_port = re_match

if re_match_length == 3:
protocol, src, dst = re.match

if re_match_length == 6:
protocol, src, dst, dst_port, icmp_type, icmp_code = re_match
Again THANK YOU very much I've learned a lot from you.
 
 
13 hours later…
10:24 PM
@joni You seem to get the hang of it now. Cool. Glad to be of assistance! Happy coding! :-)
 

« first day  last day (15 days later) »