Skip to content

Commit 4b960b6

Browse files
authored
Merge pull request #66 from akto-api-security/feature/optional_logging
add optional logs
2 parents c71c912 + a017d51 commit 4b960b6

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

ebpf-run.sh

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
1+
#!/bin/sh
2+
3+
LOG_FILE="/tmp/dump.log"
4+
MAX_LOG_SIZE=${MAX_LOG_SIZE:-10485760} # Default to 10 MB if not set (10 MB = 10 * 1024 * 1024 bytes)
5+
CHECK_INTERVAL=60 # Check interval in seconds
6+
7+
# Function to rotate the log file
8+
rotate_log() {
9+
if [ -f "$LOG_FILE" ] && [ -s "$LOG_FILE" ]; then
10+
log_size=$(stat -c%s "$LOG_FILE") # Get the size of the log file
11+
if [ "$log_size" -ge "$MAX_LOG_SIZE" ]; then
12+
echo "" > "$LOG_FILE"
13+
fi
14+
fi
15+
}
16+
17+
# Start monitoring in the background
18+
if [[ "${ENABLE_LOGS}" == "false" ]]; then
19+
while true; do
20+
rotate_log # Check and rotate logs if necessary
21+
sleep "$CHECK_INTERVAL" # Wait for the specified interval before checking again
22+
done &
23+
fi
24+
125
while :
226
do
27+
if [[ "${ENABLE_LOGS}" == "false" ]]; then
28+
./ebpf-logging >> "$LOG_FILE" 2>&1
29+
else
330
./ebpf-logging
31+
fi
432
sleep 2
5-
done
33+
done

0 commit comments

Comments
 (0)