[IntelMQ-dev] Expected behaviour of bot reloading after log rotation

Mika Silander mika.silander at csc.fi
Thu Oct 19 13:29:50 CEST 2023


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

 






More information about the IntelMQ-dev mailing list