diff --git a/salt/zeek/defaults.yaml b/salt/zeek/defaults.yaml index c68339584..24e1d8ca0 100644 --- a/salt/zeek/defaults.yaml +++ b/salt/zeek/defaults.yaml @@ -18,6 +18,7 @@ zeek: StatsLogEnable: 0 StatsLogExpireInterval: 0 StatusCmdShowAll: 0 + StopWait: 1 CrashExpireInterval: 0 SitePolicyScripts: local.zeek LogDir: /nsm/zeek/logs diff --git a/salt/zeek/disabled.sls b/salt/zeek/disabled.sls index c75cdd7b1..2025327fd 100644 --- a/salt/zeek/disabled.sls +++ b/salt/zeek/disabled.sls @@ -9,9 +9,19 @@ include: - zeek.sostatus +# Stop first so the entrypoint's SIGTERM trap can archive the final logs; docker_container.absent +# with force is a 'docker rm -f', which never delivers SIGTERM. force stays so the state still +# converges if the stop overruns. +so-zeek_stopped: + docker_container.stopped: + - name: so-zeek + - error_on_absent: False + so-zeek: docker_container.absent: - force: True + - require: + - docker_container: so-zeek_stopped so-zeek_so-status.disabled: file.comment: diff --git a/salt/zeek/enabled.sls b/salt/zeek/enabled.sls index 453990acb..ec8148e90 100644 --- a/salt/zeek/enabled.sls +++ b/salt/zeek/enabled.sls @@ -19,6 +19,10 @@ so-zeek: - restart_policy: unless-stopped - start: True - privileged: True + # Docker's default 10s grace is not enough for the entrypoint's SIGTERM trap to run + # 'zeekctl stop' and let StopWait archive the final logs. Overrunning it means SIGKILL, + # which strands those logs in spool/tmp and marks every node crashed on the next start. + - stop_timeout: 180 {% if DOCKERMERGED.containers['so-zeek'].ulimits %} - ulimits: {% for ULIMIT in DOCKERMERGED.containers['so-zeek'].ulimits %} diff --git a/salt/zeek/soc_zeek.yaml b/salt/zeek/soc_zeek.yaml index 1a12f7f5f..f1cc9e14d 100644 --- a/salt/zeek/soc_zeek.yaml +++ b/salt/zeek/soc_zeek.yaml @@ -99,6 +99,18 @@ zeek: regexFailureMessage: You must enter a whole number of days, or 0 to keep crash directories forever. helpLink: zeek advanced: True + StopWait: + description: >- + Set to 1 to make "zeekctl stop" wait for the final logs to be archived instead of + letting that finish in the background. Security Onion stops Zeek by stopping its + container, so anything still running in the background is killed when the container + exits - without this, the last logs of each run are stranded unarchived in + /nsm/zeek/spool/tmp and never reach Elasticsearch. It is read only for that reason. + regex: ^[01]$ + regexFailureMessage: You must enter 0 or 1. + helpLink: zeek + advanced: True + readonly: True MinDiskSpace: description: >- Percentage of free disk space below which ZeekControl reports a warning, or 0 to disable the check