mirror of
https://github.com/azlux/log2ram
synced 2024-11-23 22:06:10 +00:00
Compare commits
No commits in common. "ee742290cc776890c497737ec0ebbb6cc34ae249" and "dc2dd2dbad18cf8036377b30413f412240e85616" have entirely different histories.
ee742290cc
...
dc2dd2dbad
@ -16,14 +16,13 @@
|
|||||||
log2ram_keyring: /usr/share/keyrings/azlux-archive-keyring.gpg
|
log2ram_keyring: /usr/share/keyrings/azlux-archive-keyring.gpg
|
||||||
log2ram_apt_repository: "deb [signed-by={{ log2ram_keyring }}] {{ log2ram_repo_url }}/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} main"
|
log2ram_apt_repository: "deb [signed-by={{ log2ram_keyring }}] {{ log2ram_repo_url }}/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} main"
|
||||||
|
|
||||||
log2ram_size: 128M
|
log2ram_size: 40M
|
||||||
log2ram_use_rsync: true
|
log2ram_use_rsync: true
|
||||||
log2ram_notification: true
|
log2ram_mail: true
|
||||||
log2ram_notification_command: 'mail -s "Log2Ram Error on $HOSTNAME"'
|
|
||||||
log2ram_path_disk: /var/log
|
log2ram_path_disk: /var/log
|
||||||
log2ram_use_z2lr: false
|
log2ram_use_z2lr: true
|
||||||
log2ram_comp_alg: lz4
|
log2ram_comp_alg: lz4
|
||||||
log2ram_log_disk_size: 256M
|
log2ram_log_disk_size: 100M
|
||||||
|
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
@ -32,10 +31,6 @@
|
|||||||
name: rsync
|
name: rsync
|
||||||
when: log2ram_use_rsync
|
when: log2ram_use_rsync
|
||||||
|
|
||||||
- name: Install GnuPG
|
|
||||||
apt:
|
|
||||||
name: gnupg
|
|
||||||
|
|
||||||
- name: Add gpg key
|
- name: Add gpg key
|
||||||
shell:
|
shell:
|
||||||
cmd: >
|
cmd: >
|
||||||
@ -67,8 +62,7 @@
|
|||||||
loop:
|
loop:
|
||||||
- {regexp: '^SIZE=(.*)$', line: 'SIZE={{ log2ram_size }}'}
|
- {regexp: '^SIZE=(.*)$', line: 'SIZE={{ log2ram_size }}'}
|
||||||
- {regexp: 'USE_RSYNC=(.*)$', line: 'USE_RSYNC={{ log2ram_use_rsync }}'}
|
- {regexp: 'USE_RSYNC=(.*)$', line: 'USE_RSYNC={{ log2ram_use_rsync }}'}
|
||||||
- {regexp: '^NOTIFICATION=(.*)$', line: 'NOTIFICATION={{ log2ram_notification }}'}
|
- {regexp: '^MAIL=(.*)$', line: 'MAIL={{ log2ram_mail }}'}
|
||||||
- {regexp: '^NOTIFICATION_COMMAND=(.*)$', line: 'NOTIFICATION_COMMAND={{ log2ram_notification_command }}'}
|
|
||||||
- {regexp: '^PATH_DISK=(.*)$', line: 'PATH_DISK="{{ log2ram_path_disk }}"'}
|
- {regexp: '^PATH_DISK=(.*)$', line: 'PATH_DISK="{{ log2ram_path_disk }}"'}
|
||||||
- {regexp: '^ZL2R=(.*)$', line: 'ZL2R={{ log2ram_use_z2lr|lower }}'}
|
- {regexp: '^ZL2R=(.*)$', line: 'ZL2R={{ log2ram_use_z2lr|lower }}'}
|
||||||
- {regexp: '^COMP_ALG=(.*)$', line: 'COMP_ALG={{ log2ram_comp_alg }}'}
|
- {regexp: '^COMP_ALG=(.*)$', line: 'COMP_ALG={{ log2ram_comp_alg }}'}
|
||||||
|
8
log2ram
8
log2ram
@ -46,10 +46,10 @@ sync_to_disk() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${NO_RSYNC}" ] && [ -x "$(command -v rsync)" ]; then
|
if [ -z "${NO_RSYNC}" ] && [ -x "$(command -v rsync)" ]; then
|
||||||
rsync -aXv --sparse --inplace --no-whole-file --delete-after "${optional_params[@]}" "$RAM_LOG"/ "$HDD_LOG"/ 2>&1 |
|
rsync -aXv --inplace --no-whole-file --delete-after "${optional_params[@]}" "$RAM_LOG"/ "$HDD_LOG"/ 2>&1 |
|
||||||
tee -a "$LOG2RAM_LOG"
|
tee -a "$LOG2RAM_LOG"
|
||||||
else
|
else
|
||||||
cp -rfup --sparse=always "$RAM_LOG"/ -T "$HDD_LOG"/ 2>&1 | tee -a "$LOG2RAM_LOG"
|
cp -rfup "$RAM_LOG"/ -T "$HDD_LOG"/ 2>&1 | tee -a "$LOG2RAM_LOG"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,9 +75,9 @@ sync_from_disk() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${NO_RSYNC}" ] && [ -x "$(command -v rsync)" ]; then
|
if [ -z "${NO_RSYNC}" ] && [ -x "$(command -v rsync)" ]; then
|
||||||
rsync -aXv --sparse --inplace --no-whole-file --delete-after "$HDD_LOG"/ "$RAM_LOG"/ 2>&1 | tee -a "$LOG2RAM_LOG"
|
rsync -aXv --inplace --no-whole-file --delete-after "$HDD_LOG"/ "$RAM_LOG"/ 2>&1 | tee -a "$LOG2RAM_LOG"
|
||||||
else
|
else
|
||||||
cp -rfup --sparse=always "$HDD_LOG"/ -T "$RAM_LOG"/ 2>&1 | tee -a "$LOG2RAM_LOG"
|
cp -rfup "$HDD_LOG"/ -T "$RAM_LOG"/ 2>&1 | tee -a "$LOG2RAM_LOG"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
71
log2ram.conf
71
log2ram.conf
@ -1,32 +1,31 @@
|
|||||||
# Configuration file for Log2Ram (https://github.com/azlux/log2ram) under MIT license.
|
# Configuration file for Log2Ram (https://github.com/azlux/log2ram) under MIT license.
|
||||||
# This configuration file is read by the log2ram service
|
# This configuration file is read by the log2ram service
|
||||||
|
|
||||||
# Specify the amount of RAM reserved for storing logs. This setting determines the maximum size of the RAM folder.
|
# Size for the ram folder, it defines the size the log folder will reserve into the RAM.
|
||||||
# Ensure 'SIZE=' is set larger than the current size of your /var/log directory to prevent startup failures.
|
# If it's not enough, log2ram will not be able to use ram. Check you /var/log size folder.
|
||||||
# Also, configure logrotate to manage log growth and prevent the /var/log directory from exceeding this reserved size.
|
# The default is 40M and is basically enough for a lot of applications.
|
||||||
# The default setting of 128M suffices for many typical applications, but you may need to increase it for
|
# You will need to increase it if you have a server and a lot of log for example.
|
||||||
# servers or systems that generate extensive logging.
|
|
||||||
SIZE=128M
|
SIZE=128M
|
||||||
|
|
||||||
# Select the log syncing method between disk and RAM:
|
# Select the log syncing method between the log directory on disk and in the RAM.
|
||||||
# - 'rsync' is the default unless 'USE_RSYNC' is set to 'false'.
|
# The variable may be uncommented out, setting it to false, if "cp" is preferred over "rsync".
|
||||||
# - If 'rsync' is unavailable, 'cp' is automatically used as a fallback.
|
# Currently, this option needs to be unset or set to true for "rsync" to run,
|
||||||
# - Set 'USE_RSYNC' to 'false' to explicitly use 'cp'.
|
# with "cp" available for fallback when "rsync" is missing.
|
||||||
|
# In all other cases, setting USE_RSYNC to anything other than true will default to "cp".
|
||||||
#USE_RSYNC=false
|
#USE_RSYNC=false
|
||||||
|
|
||||||
# By default, if there is insufficient RAM space, a system notification email is sent.
|
# If there are some errors with available RAM space, a system mail will be send by default (see next parameter)
|
||||||
# Set this to 'false' to disable email notifications. (The error will still be logged locally).
|
# Change it to false and you will have only a log if there is no place on RAM anymore.
|
||||||
#NOTIFICATION=true
|
#NOTIFICATION=true
|
||||||
|
|
||||||
# Specify the command for sending error notifications.
|
# This is a one-line command for the error notification.
|
||||||
# By default, it uses the `mail` command to send an email, with the message body provided via stdin.
|
# By default, it's a email with the command `mail`, the body is passed in stdin.
|
||||||
# You can replace this with any command (such as 'shoutrrr') or a custom script for handling notifications.
|
# So you can set any command(like shoutrrr) or custom script for the error notification.
|
||||||
#NOTIFICATION_COMMAND=mail -s "Log2Ram Error on $HOSTNAME"
|
#NOTIFICATION_COMMAND=mail -s "Log2Ram Error on $HOSTNAME"
|
||||||
|
|
||||||
# Specify the directories to be stored in RAM. List each directory using its absolute path, e.g., `/path/folder`.
|
# Variable for folders to put in RAM. You need to specify the real folder `/path/folder` , the `/path/hdd.folder` will
|
||||||
# Corresponding directories on the HDD, named `/path/hdd.folder`, will be automatically created for each listed path.
|
# be automatically created. Multiple path can be separeted by `;`. Do not add the final `/` !
|
||||||
# Separate multiple paths with a semicolon `;` and do not include a trailing slash at the end of the paths.
|
# example : PATH_DISK="/var/log;/home/test/FolderInRam"
|
||||||
# Example: PATH_DISK="/var/log;/home/test/FolderInRam"
|
|
||||||
PATH_DISK="/var/log"
|
PATH_DISK="/var/log"
|
||||||
|
|
||||||
# Should log2ram consider journald and do a log rotate before copying the log files back? Please note that for this
|
# Should log2ram consider journald and do a log rotate before copying the log files back? Please note that for this
|
||||||
@ -34,33 +33,17 @@ PATH_DISK="/var/log"
|
|||||||
# ram folder is will probably not be as large as journald will use by default
|
# ram folder is will probably not be as large as journald will use by default
|
||||||
JOURNALD_AWARE=true
|
JOURNALD_AWARE=true
|
||||||
|
|
||||||
# Set to 'true' to enable log rotation for journald logs before syncing.
|
# **************** Zram backing conf *************************************************
|
||||||
# Note: 'rsync' must be used for this feature.
|
|
||||||
# Ensure 'SystemMaxUse' is configured in 'journald.conf'
|
|
||||||
# - (To limit journald’s disk usage to be smaller than the log2ram RAM allocation).
|
|
||||||
JOURNALD_AWARE=true
|
|
||||||
|
|
||||||
|
# ZL2R Zram Log 2 Ram enables a zram drive when ZL2R=true ZL2R=false is mem only tmpfs
|
||||||
# **************** Zram backing conf ****************
|
|
||||||
|
|
||||||
# Set ZL2R=true to enable zram, providing compressed RAM storage for log2ram.
|
|
||||||
# Set ZL2R=false to use tmpfs, which provides uncompressed memory-only storage.
|
|
||||||
ZL2R=false
|
ZL2R=false
|
||||||
|
# COMP_ALG this is any compression algorithm listed in /proc/crypto
|
||||||
# Choose a compression algorithm from those listed in /proc/crypto.
|
# lz4 is fastest with lightest load but deflate (zlib) and Zstandard (zstd) give far better compression ratios
|
||||||
# 'lz4' is the fastest, offering the lightest CPU load but lower compression ratios.
|
# lzo is very close to lz4 and may with some binaries have better optimisation
|
||||||
# 'deflate' (zlib) and 'Zstandard' (zstd) provide higher compression ratios but use more CPU.
|
# COMP_ALG=lz4 for speed or Zstd for compression, lzo or zlib if optimisation or availabilty is a problem
|
||||||
# 'lzo' is similar to 'lz4' but may perform better with certain binaries due to optimizations.
|
|
||||||
# Set COMP_ALG to 'lz4' for speed, 'zstd' for better compression, or 'lzo' or 'zlib' if optimizations or availability are concerns.
|
|
||||||
COMP_ALG=lz4
|
COMP_ALG=lz4
|
||||||
|
# LOG_DISK_SIZE is the uncompressed disk size. Note zram uses about 0.1% of the size of the disk when not in use
|
||||||
# LOG_DISK_SIZE specifies the uncompressed zram disk size.
|
# LOG_DISK_SIZE is expected compression ratio of alg chosen multiplied by log SIZE
|
||||||
# (Sets the size of the zram disk that will be presented to the operating system).
|
# lzo/lz4=2.1:1 compression ratio zlib=2.7:1 zstandard=2.9:1
|
||||||
# To estimate amount of RAM this will consume, divide LOG_DISK_SIZE by your chosen compression algorithm's ratio:
|
# Really a guestimate of a bit bigger than compression ratio whilst minimising 0.1% mem usage of disk size
|
||||||
# - lzo/lz4 typically compresses at a ratio of 2.1:1
|
|
||||||
# - zlib compresses at about 2.7:1
|
|
||||||
# - zstandard (zstd) achieves around 2.9:1
|
|
||||||
# Example calculation using lz4:
|
|
||||||
# Given LOG_DISK_SIZE = 256M (which represents 256 Megabytes of uncompressed log data),
|
|
||||||
# the estimated zram RAM usage = 256 MB / 2.1 ≈ 122 MB of RAM.
|
|
||||||
LOG_DISK_SIZE=256M
|
LOG_DISK_SIZE=256M
|
||||||
|
Loading…
Reference in New Issue
Block a user