-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Script fails to execute #2
Comments
pyfwlog script is designed to parse iptables log files, not full kernel log files. It's clear from your second traceback that it's trying to index a line item that doesn't match the regex, hence the KeyError. Filter out your iptables to a seperate log file, and specifiy this with the -l flag. |
Hi, sorry you're right and thanks for the quick reply. Is there a way I can pipe the output of I would like the analysis to be ongoing and refresh by increments of 1 second. |
Hi, no worries! You can use rsyslog to filter out iptables logs based on the iptables --log-prefix option to a log file.. Rsyslog in combination with logrorate.d means the files are rotated once a day for example, so the script only outputs recently dropped connections. I've been using this on all my servers as a snapshot command of who has been knocking on the front door, so it was written to be a parser of a log file on demand, rather than a running process that constantly updates every x seconds. I like the idea of having a flag that loops through the log file and displays new line items as they are logged / dropped in real time. I'm actually refactoring the code for this project, due to the Ubuntu 23.04 python package changes (you can't install pip packages to the world anymore). I plan to wrap the script and it's module dependencies into an executable (i've done this roughly for my own purposes recently) and package into a *.deb and *.rpm file respectively for easy install / distribution. Since i'm tidying this all up, i'll take a look at adding a -t flag for "tailing" the log file in real time. Watch this space! |
Yeah exactly that's possible with the rsyslog package. I think I've filtered them like this once by --log-level but didn't like that other messages were also included like interfaces entering/exiting promiscuous mode etc. If it's possible to grab anything with a --log-prefix (possibly with a regex) instead of specific ones, that might be interesting, but I have hundreds of different prefixes on my server. |
System: Debian Bookworm
Dependencies have been installed.
rich via
apt-get install python3-rich
file-read-backwards was built from source
Command:
sudo python3 py_fw_log.py -l /var/log/kern.log -s 50
The text was updated successfully, but these errors were encountered: