File tree Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change
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
+
1
25
while :
2
26
do
27
+ if [[ " ${ENABLE_LOGS} " == " false" ]]; then
28
+ ./ebpf-logging >> " $LOG_FILE " 2>&1
29
+ else
3
30
./ebpf-logging
31
+ fi
4
32
sleep 2
5
- done
33
+ done
You can’t perform that action at this time.
0 commit comments