Skip to content

Commit

Permalink
update rsyslog log size conf (#15821)
Browse files Browse the repository at this point in the history
Why I did it
For some devices whose log folder size is larger than 200M, for example, 256M, the LOG_FILE_ROTATE_SIZE_KB should be 16M. and
THRESHOLD_KB=$((USABLE_SPACE_KB - (NUM_LOGS_TO_ROTATE * LOG_FILE_ROTATE_SIZE_KB * 2)))
= $(( (VAR_LOG_SIZE_KB * 90 / 100) - RESERVED_SPACE_KB)) - (NUM_LOGS_TO_ROTATE * LOG_FILE_ROTATE_SIZE_KB * 2)))
= $(( (256M * 90 / 100) - 4096)) - (8 * 16M * 2)))
the result would be a negative value

Work item tracking
Microsoft ADO (number only):
24524827
How I did it
Add a case for 400M, if the log folder size is between 200M and 400M, set the log file size to 2M

How to verify it
Do cmd "sudo logrotate -f /etc/logrotate.conf" on DUT which val/log folder size is 256M, and check the syslog.
  • Loading branch information
lipxu authored Jul 14, 2023
1 parent 1bf2a61 commit 95d1197
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions files/image_config/logrotate/rsyslog.j2
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
{
{% if var_log_kb <= 204800 %}
size 1M
{% elif var_log_kb <= 409600 %}
size 2M
{% else %}
size 16M
{% endif %}
Expand All @@ -52,6 +54,8 @@
# Adjust LOG_FILE_ROTATE_SIZE_KB to reflect the "size" parameter specified above, in kB
{% if var_log_kb <= 204800 %}
LOG_FILE_ROTATE_SIZE_KB=1024
{% elif var_log_kb <= 409600 %}
LOG_FILE_ROTATE_SIZE_KB=2048
{% else %}
LOG_FILE_ROTATE_SIZE_KB=16384
{% endif %}
Expand Down

0 comments on commit 95d1197

Please sign in to comment.