Hi Kamil,
Thanks for your response. I did some more log file scrutiny and found out that when I run as root:
sudo -u intelmq /usr/bin/intelmqctl --quiet reload
that is, the same command that gets run from logrotate, the result is a log line containing
" ... Received SIGHUP, initializing again later."
in only the Mail Attachment Collector's log file. No sign of it in other bots' log files. There are no _sighup_delay settings configured for any of the bots in our botnet. Roughly one minute after the SIGHUP message was logged, the Mail Attachment Collector writes
" ... Handling SIGHUP, initializing again now."
to the log and reloads. So, is the signal delivery to one bot only expected behaviour in the context of reloads? I assumed SIGHUP would be delivered to all bots in the botnet. I recall OS specs say signals are delivered on a best-effort basis, so it means delivery is not guaranteed. I ran the above reload command several times and all of the times, SIGHUP was only seen by the Mail Attachment Collector(?!?!)
I'll continue debugging.
Best regards, Mika
----- Original Message ----- From: "Kamil Mankowski via IntelMQ-dev" intelmq-dev@lists.cert.at To: "intelmq-dev" intelmq-dev@lists.cert.at Sent: Thursday, 19 October, 2023 15:35:42 Subject: Re: [IntelMQ-dev] Expected behaviour of bot reloading after log rotation
Hey,
There is a bot's flag ("_sighup_delay") controlling weather a bot reloads immediate or waits. Looking at the source code, it looks like an expected behaviour, see:
https://github.com/certtools/intelmq/blob/d624988693894e71defdd8b18618f7af98...
and:
https://github.com/certtools/intelmq/blob/d624988693894e71defdd8b18618f7af98...
However, I understand your concern: this is okay if the reload happens during the one day (logrotate keeps the old log file untouched until next run), but it can cause troubles, if there is no message on one day.
Best regards, Kamil Mankowski CERT.at GmbH www.cert.at
On 10/19/23 13:29, Mika Silander wrote:
Hi all,
Apologies for a lengthy message, but I had a set of monitoring scripts that worked like a charm on a physical machine but when moved to a virtual machine with a newer Ubuntu, I see odd failures in the form of monitoring script processes left hanging on void file handles. I suspect the problem is somehow related to log rotation in connection to bot reloading but I can't figure out how. A few questions at the end.
Our setup for reference:
Ubuntu 22.04 LTS python 3.10.12 intelmq 3.2.2a1 intelmq-api 3.1.0-rc1 intelmq-manager 3.2.0
We have a simple bot chain: Mail Attachment Collector -> Shadowserver Parser -> N expert bots -> 1 output bot.
/etc/logrotate.d/intelmq contains:
/var/log/intelmq/*.log { su intelmq intelmq daily maxsize 10M rotate 60 notifempty compress delaycompress create 644 intelmq intelmq sharedscripts postrotate sudo -u intelmq /usr/bin/intelmqctl --quiet reload endscript }
The cron daemon runs run-parts for targets under /etc/cron.daily/ at 06:25, including /etc/cron.daily/logrotate. Thus, "intelmqctl --quiet reload" gets also executed after all the intelmq log files have been rotated.
What I see is that no bot reloads soon after run-parts has finished. The first bot to perform a reload is the Mail Attachment Collector immediately after midnight. The others remain as is until the Mail Attachment Collector reads the day's first report and forwards it to the Shadowserver Parser bot. The parser bot then performs a reload and forwards the events to the first expert in the chain. Once the first event from the parser trickles through the entire bot chain, every bot in turn first performs a reload and then processes the event. In practise, the logrotate triggered bot reload can thus be delayed almost a full day - our first mail reports tend to arrive during the very early morning hours.
My question is, is the above reload behaviour as expected? I found it strange that the Mail Attachment Collector reloads at midnight even though it has processed new mail reports after the "intelmqctl reload" call done by logrotate. I would have expected the Mail Attachment Collector to reload itself when the first report arrives for processing after 06:25, i.e. the first report after the call to intelqmctl reload. And, what controls the timing of the Mail Attachment Collector's reload? All its reloads I see in older log files indicate that the reload is consistently run after midnight irrespective of incoming reports and the timing of the intelmqctl reload command.
Thanks again and best regards from a puzzled Mika
IntelMQ-dev mailing list https://lists.cert.at/cgi-bin/mailman/listinfo/intelmq-dev https://intelmq.readthedocs.io/
_______________________________________________ IntelMQ-dev mailing list https://lists.cert.at/cgi-bin/mailman/listinfo/intelmq-dev https://intelmq.readthedocs.io/