childmem is a command-line tool that monitors the memory usage of child processes of a specified parent process on Linux systems using procfs.
go build -o childmem .The childmem tool requires either a parent process name (-pname) or a parent process ID (-ppid) to identify the target process. It outputs the child process information to a CSV file, defaulting to child_mem.csv.
./childmem -pname <parent_process_name> [-output <output_file.csv>]
./childmem -ppid <parent_process_id> [-output <output_file.csv>]-pname <name>: The name of the parent process to monitor.-ppid <pid>: The PID of the parent process to monitor.-includeParent: (Optional) Include the parent process in the output.-output <file>: (Optional) Path to the output CSV file. Defaults to./child_mem.csv.
docker build -t childmem -f build/Dockerfile .docker run --security-opt=no-new-privileges --pid=host -v ./data:/app/data childmem# Custom interval and process name
docker run -e INTERVAL=10 -e PNAME="nginx" --security-opt=no-new-privileges --pid=host -v ./data:/app/data childmemINTERVAL: Seconds between runs (default: 30)PNAME: Process name to monitor (default: "mattermost")
childmemruns as non-root user (UID/GID 1000) inside container- Requires
--pid=hostto access host process information - Ensure the data directory on the host is owned by UID 1000 (
sudo chown -R 1000:1000 ./data)