Disable CHECK_INTERVAL when using journalctl #49
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If we are getting all our data from journalctl, I don't see a point in using the old polling method. This is an attempt to allow psad to wait for IO activity instead of waiting for a timeout.
I am using this for my personal servers with no ill effects. I am not asking you to accept this pull request but I do ask that you consider the idea.
Since
can_read()
blocks by default, I removed the timeout to allow psad to wait until it receives activity from the child process watching journalctrl (well actually I gave it a timeout of 120 since I guess we would not want it to accidentally block forever if the background process got killed). Once activity is detected we enter a second state defined by thewhile
loop that callscan_read()
with a short timeout. This is due to the fact that since we are reading from a pipe, we will never get an EOF and thus a normal read would block forever. Once the second read times out, the process then flows though the normal process (minus the lastsleep $config{'CHECK_INTERVAL'}
).I did add a hard limit of
@fw_packets < 10
since on a busy host this read would never time out, though perhaps we could set it to$config{'FW_MSG_READ_MIN_PKTS'}