In order to avoid repeating old alerts you tell how far you have read the file and keep that as a reference so that every time you read the file you can seek to the last position and avoid reading of old lines. This way you can also avoid storing huge amount of lines in the memory as you only read the latest additions. Of course you have to be aware that most of the logs are rotated sometimes so you need to reset the file pointer occasionally. You can use stat to find out when the file has changed (the file size usually shrinks when it is rotated).
And you really should sleep at least for a second to avoid busy loops and to allow Ctrl-C to arrive faster.
What if the log has 5000 new lines since the last time you read it? Do you fill the screen with 5000 alerts?
In reply to Re: read from network security log file and display lines as alert boxes
by puudeli
in thread read from network security log file and display lines as alert boxes
by whistler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |