Skip to content

System tools

Christophe TREMBLAY-GUILLOUX
Christophe TREMBLAY-GUILLOUXLinux systems engineer

Collecting the contents of every .htaccess file of a website

Section titled “Collecting the contents of every .htaccess file of a website”

Since we use NGINX and not Apache, the contents of the .htaccess files have to be checked to know what needs to be implemented as an equivalent NGINX rule:

bash
collect-htaccess.sh <user> [subdirectory]

Measuring the memory footprint of a gunicorn worker

Section titled “Measuring the memory footprint of a gunicorn worker”

Workers are forked from the master and share part of their pages: RSS therefore counts the same memory several times. PSS is the figure to read.

bash
for pid in $(cat /sys/fs/cgroup/system.slice/<service>.service/cgroup.procs); do
printf '%6s %5s MB %s\n' "$pid" \
"$(( $(awk '/^Pss:/{print $2}' /proc/$pid/smaps_rollup) / 1024 ))" \
"$(tr '\0' ' ' < /proc/$pid/cmdline | cut -c1-60)"
done

The first PID is the master, the following ones are the workers. The total for the service, as a cross-check:

bash
systemctl show -p MemoryCurrent <service>.service

Measure after real traffic, not right after startup: the footprint grows with loaded modules and caches. The value of one worker, rounded up, goes into per_worker_mb of the site's hiera declaration, which is used to compute the number of workers. Repeat after a major version upgrade or after adding a heavy dependency.