# EDON Argos: rotation of the DPI engines' logs (installed as
# /etc/logrotate.d/argos-dpi by the argos package, run by logrotate.timer).
# argos follows eve.json and notice.log from an offset and starts over on a
# new inode, so both stanzas rotate by renaming, never by copytruncate.

# Suricata opens its logs with O_APPEND and reopens them on SIGHUP (at its next
# write): rename, then signal the unit's main process once. tls.json is the
# handshakes (the fingerprint eve instance), appid.json App-ID's flows, DNS
# answers and HTTP names, and stats.log the counters; all of them sit
# beside eve.json (default-log-dir), never under /var/log/suricata, where the
# suricata package's own snippet signals a pid file only its service writes.
# The rotated files stay uncompressed for one day, so a record written between
# the rename and the reopen is never compressed away.
/var/lib/argos-dpi/suricata/eve.json /var/lib/argos-dpi/suricata/tls.json /var/lib/argos-dpi/suricata/appid.json /var/lib/argos-dpi/suricata/stats.log {
	daily
	rotate 7
	missingok
	notifempty
	create
	compress
	delaycompress
	sharedscripts
	postrotate
		systemctl kill --signal=HUP --kill-whom=main argos-suricata.service >/dev/null 2>&1 || true
	endscript
}

# Zeek runs one instance per tapped interface, each logging in its own
# directory. It never reopens a log: SIGHUP rotates nothing, and
# it writes without O_APPEND, so copytruncate would leave a sparse file that
# never shrinks. Every log is renamed, then the passive tap restarts once (a
# few seconds without analysis; no traffic waits on Zeek). A stopped unit stays
# stopped. The restart has closed the old files before they are compressed.
/var/lib/argos-dpi/zeek/*/*.log {
	daily
	rotate 7
	missingok
	notifempty
	create
	compress
	sharedscripts
	postrotate
		systemctl try-restart 'argos-zeek@*.service' >/dev/null 2>&1 || true
	endscript
}
