Merge pull request #3012 from Security-Onion-Solutions/issue/2989

Issue/2989
This commit is contained in:
Josh Patterson
2021-02-18 10:52:23 -05:00
committed by GitHub
2 changed files with 5 additions and 11 deletions

View File

@@ -24,15 +24,9 @@ read lastPID < $lf
[ ! -z "$lastPID" -a -d /proc/$lastPID ] && exit
echo $$ > $lf
MAXEVES={{ salt['pillar.get']('suricata:cleanup:eve_json', 20) }}
if [ "$MAXEVES" -lt 2 ]; then
MAXEVES=2
MAXDAYS={{ salt['pillar.get']('suricata:cleanup:eve_json', 7) }}
if [ "$MAXDAYS" -lt 1 ]; then
MAXDAYS=1
fi
# Find eve files and remove them
NUMEVES=$(find /nsm/suricata/ -type f -name "eve-*.json" | wc -l)
while [ "$NUMEVES" -gt "$MAXEVES" ]; do
OLDESTEVE=$(find /nsm/suricata/ -type f -name "eve-*.json" -type f -printf '%T+ %p\n' | sort | head -n 1 | awk -F" " '{print $2}')
rm -f $OLDESTEVE
NUMEVES=$(find /nsm/suricata/ -type f -name "eve-*.json" | wc -l)
done
find /nsm/suricata/ -type f -mtime +$MAXDAYS -name 'eve-*.json*' -execdir rm -- '{}' \;

View File

@@ -1,6 +1,6 @@
#!/bin/bash
# Gzip the eve logs
find /nsm/suricata/eve*.json -type f -printf '%T@\t%p\n' | sort -t $'\t' -g | head -n -1 | cut -d $'\t' -f 2- | xargs nice gzip
find /nsm/suricata/eve*.json -type f -printf '%T@\t%p\n' | sort -t $'\t' -g | head -n -1 | cut -d $'\t' -f 2 | xargs nice gzip
# TODO Add stats log