From 4162127058b85e5c197056c2f20540c96ff97cc1 Mon Sep 17 00:00:00 2001 From: PavelKuzub Date: Mon, 25 Jan 2021 03:33:51 -0500 Subject: [PATCH] Added container-common for #100 (#102) * Added container-common Initial release of container-common section that includes setting a limit of container log size any container can have, to prevent filling up UDM storage with excessive logging. * Update README.md Clarified description of max log size Co-authored-by: TRUPaC --- README.md | 4 +++ container-common/README.md | 36 +++++++++++++++++++ .../on_boot.d/05-container-common.sh | 5 +++ homebridge/README.md | 1 + 4 files changed, 46 insertions(+) create mode 100644 container-common/README.md create mode 100644 container-common/on_boot.d/05-container-common.sh diff --git a/README.md b/README.md index 1e17633b..17131ee8 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,14 @@ Pull Requests welcome! If you use this functionality to do new cool stuff to you ### suricata Run an updated version of suricata and apply custom rules that survive reboot + ### on-boot-script Do this first. Enables init.d style scripts to run on every boot of your UDM. Includes examples to run wpa-supplicant/eap-proxy and/or ntop-ng on startup. Follow this [readme](https://github.com/boostchicken/udm-utilities/blob/master/on-boot-script/README.md). **It enables complete customization of your UDM/P and fills the gap that config.gateway.json left behind.** +### container-common +Apply this after on-boot-script. Updates container defaults to maintain **stable disk usage footprint** of custom containers. **Prevents logs filling up UDM storage full**. + ### python If you need python3 on your UDM, generally not recommended, can always use it in unifi-os container diff --git a/container-common/README.md b/container-common/README.md new file mode 100644 index 00000000..03a7778b --- /dev/null +++ b/container-common/README.md @@ -0,0 +1,36 @@ +# Container common settings + +## Features + +1. **Stable disk usage footprint**: Sets a maximum log size any podman container log is allowed to grow up to (from unlimited size to 100Mb). Log "max size" is not a hard limit, but a point when Container Monitor attempts to truncate container log file. **NOTE:** application-specific logs that may be written outside container logs are not truncated by Container Monitor at set limits. + +## Requirements + +1. You have already setup the on boot script described [here](https://github.com/boostchicken/udm-utilities/tree/master/on-boot-script) + +## Customization + +While a 100Mb log limit per container should give plenty of log data for all featured in this repo projects, you can increase or decrease max_log_size value in /mnt/data/on_boot.d/05-container-common.sh file after installation. + +## Steps + +1. Run as root on UDM Pro to download and set permissions of on_boot.d script: +```sh +# Download 05-container-common.sh from GitHub +curl -L https://raw.githubusercontent.com/boostchicken/udm-utilities/master/container-common/on_boot.d/05-container-common.sh -o /mnt/data/on_boot.d/05-container-common.sh; +# Set execute permission +chmod a+x /mnt/data/on_boot.d/05-container-common.sh; +``` +2. Review the script /mnt/data/on_boot.d/05-container-common.sh and when happy execute it. +```sh +# Review script +cat /mnt/data/on_boot.d/05-container-common.sh; +# Apply container-common settings +/mnt/data/on_boot.d/05-container-common.sh; +``` +3. Already running containers will pick up new defaults after either container restart ("podman restart \") or after UDM Pro restart. New containers will pick up a change from first run. +4. To list containers that are running with log size limits: +```sh +# List container monitor processes with "--log-size-max" custom argument set +ps -ef | grep conmon | grep log-size-max +``` diff --git a/container-common/on_boot.d/05-container-common.sh b/container-common/on_boot.d/05-container-common.sh new file mode 100644 index 00000000..35874845 --- /dev/null +++ b/container-common/on_boot.d/05-container-common.sh @@ -0,0 +1,5 @@ +#!/bin/sh +# This script runs before any custom containers start to adjust container common defaults + +# Set a limit for container logs. 104857600 Bytes = 100 Megabytes +sed -i 's/max_log_size = -1/max_log_size = 104857600/g' /etc/containers/libpod.conf; diff --git a/homebridge/README.md b/homebridge/README.md index eeb2a434..d8b8ed8a 100644 --- a/homebridge/README.md +++ b/homebridge/README.md @@ -7,6 +7,7 @@ ### Requirements 1. You have successfully setup the on boot script described [here](https://github.com/boostchicken/udm-utilities/tree/master/on-boot-script). +2. You have applied [container-common](https://github.com/boostchicken/udm-utilities/tree/master/container-common) change to prevent UDM storage to fill up with Homebridge logs and addon error messages that can move fast. ### Customization