From e8adea3022819d008a3f8efef320f1c5989518ef Mon Sep 17 00:00:00 2001 From: Jason Ertel Date: Sat, 7 Mar 2026 08:20:08 -0500 Subject: [PATCH] restore pcapout since it's still used --- salt/common/tools/sbin/so-sensor-clean | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/salt/common/tools/sbin/so-sensor-clean b/salt/common/tools/sbin/so-sensor-clean index ecd4593e2..472663bb1 100755 --- a/salt/common/tools/sbin/so-sensor-clean +++ b/salt/common/tools/sbin/so-sensor-clean @@ -72,6 +72,22 @@ clean() { done fi + ## Clean up extracted pcaps from Steno + PCAPS='/nsm/pcapout' + OLDEST_PCAP=$(find $PCAPS -type f -printf '%T+ %p\n' | sort -n | head -n 1) + if [ -z "$OLDEST_PCAP" -o "$OLDEST_PCAP" == ".." -o "$OLDEST_PCAP" == "." ]; then + echo "$(date) - No old files available to clean up in $PCAPS" >>$LOG + else + OLDEST_PCAP_DATE=$(echo $OLDEST_PCAP | awk '{print $1}' | cut -d+ -f1) + OLDEST_PCAP_FILE=$(echo $OLDEST_PCAP | awk '{print $2}') + echo "$(date) - Removing extracted files for $OLDEST_PCAP_DATE" >>$LOG + find $PCAPS -type f -printf '%T+ %p\n' | grep $OLDEST_PCAP_DATE | awk '{print $2}' | while read FILE; do + echo "$(date) - Removing file: $FILE" >>$LOG + rm -f "$FILE" + done + fi +} + # Check to see if we are already running NUM_RUNNING=$(pgrep -cf "/bin/bash /usr/sbin/so-sensor-clean") [ "$NUM_RUNNING" -gt 1 ] && echo "$(date) - $NUM_RUNNING sensor clean script processes running...exiting." >>$LOG && exit 0