On Wed, May 31, 2017 at 06:55:31PM -0500, Jason L Tibbitts III wrote:
>>>>> "ZJ" == Zbigniew Jędrzejewski-Szmek
<zbyszek(a)in.waw.pl> writes:
ZJ> I you post the code somewhere, I could have a look.
It's in the upstream "journal" branch of the denyhosts source:
https://github.com/denyhosts/denyhosts/tree/journal
https://github.com/denyhosts/denyhosts/commit/d0d66a2890d50a460ecd20ee0b1...
The meat is in DenyHosts/deny_hosts.py. The code is mostly a mess
because it's an attempt to cram journal processing into an existing main
loop, and a lot of the diff is just reindentation. My intent was to
make sure the simple approach worked first and then refactor things to
make it less unpleasant.
Really all it's doing is "self.__journal =
journal.Reader()", then
adding some match clauses with disjunctions in between, and maybe
loading a saved cursor and seeking to it. The main loop is just doing
"for entry in self.__journal:", but after running for some long period
of time (usually days) that ends up blocking forever waiting for the
next entry.
IIUC, the code does a sleep loop, and does not use polling. So it's
not particularly efficient, but it should work. If it hangs after a
few days, it sounds like it's hitting some race condition...
DAEMON_SLEEP is 30s, and that's long enough for all journal files to
be rotated away, sometimes. That should not be a problem, but maybe
this is tickling some bug in the journal code? I don't think we had
reports of such a problem, but there aren't that many independent
implementations of journal clients, so it's certainly possible that
some bugs are lurking.
I launched a script that tries to do the same, I'll let it run for
a few days [1] and see. Sorry, I don't think I can help. One suggestion
would be to attach gdb to the hanging script and look the sd_journal
object.
[1]
https://paste.fedoraproject.org/paste/TakEtY0~9Knwc-G583NjO15M1UNdIGYhyRL...
Zbyszek