Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory-monitor: Fix log files clean up to prevent storage overflow. #4331

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pkg/memory-monitor/src/monitor/memory-monitor-handler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,12 @@ for dir in */; do
fi
done

MEMORY_MONITOR_HANDLER_LOG_FILE="memory-monitor-handler.log"

# Remove old archives, do not keep more than 100 MB of archives
total_size=$(du -s | awk '{print $1}') # Size in KB
# Subtract the size of the handler log file
total_size=$((total_size - $(stat -c %s memory-monitor-handler.log) / 1024))
total_size=$((total_size - $(stat -c %s "$MEMORY_MONITOR_HANDLER_LOG_FILE") / 1024))
# Subtract the size of the psi.txt file (if it exists) as it size is regulated by the PSICollector
if [ -f psi.txt ]; then
total_size=$((total_size - $(stat -c %s psi.txt) / 1024))
Expand All @@ -201,5 +203,5 @@ while [ "$total_size" -gt 102400 ]; do
# Remove the first line from the events.log file: it contains the oldest event info
sed -i '1d' events.log
total_size=$(du -s | awk '{print $1}')
total_size=$((total_size - $(stat -c %s handler.log) / 1024))
total_size=$((total_size - $(stat -c %s "$MEMORY_MONITOR_HANDLER_LOG_FILE") / 1024))
done
Loading