
El diario SystemD limita los mensajes registrados según RateLimitIntervalSec
las RateLimitBurst
opciones de configuración global. Existe la posibilidad de cambiar esos valores por unidad/servicio específico usando LogRateLimitIntervalSec
y LogRateLimitBurst
directivas. Lamentablemente, no puedo hacer que estas opciones por servicio funcionen. Espero que me ayuden a encontrar lo que estoy haciendo mal o a confirmar que hay algún problema con systemd.
Mi entorno:
# uname -srvmpio
Linux 4.18.0-193.14.2.el8_2.x86_64 #1 SMP Sun Jul 26 03:54:29 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
# cat /etc/centos-release
CentOS Linux release 8.2.2004 (Core)
# systemctl --version
systemd 239
+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=legacy
# rsyslogd -v
rsyslogd 8.1911.0-3.el8 (aka 2019.11)
Asegúrese de que los límites globales del diario se dejen de forma predeterminada en /etc/systemd/journald.conf
:
[Journal]
#RateLimitIntervalSec=30s
#RateLimitBurst=10000
y reiniciar si fuera necesario algún cambio
systemctl restart systemd-journald
Prepare el guión de prueba /root/test.sh
:
#!/bin/bash
for i in {1..1000000}
do
echo "Hello world $i"
done
Prepare la unidad de servicio de prueba /root/test.service
:
[Unit]
Description=Test limit service
[Service]
Type=simple
WorkingDirectory=/root
ExecStart=/root/test.sh
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=test
LogRateLimitIntervalSec=0
LogRateLimitBurst=0
[Install]
WantedBy=multi-user.target
Asegúrese de que el límite de velocidad de rsyslog esté desactivado cambiando /etc/rsyslog.conf
:
module(load="imjournal"
StateFile="imjournal.state"
Ratelimit.Interval="0")
Configure la ubicación del archivo de registro del servicio de prueba creando /etc/rsyslog.d/test.conf
:
if ($programname == 'test') then {
action(
type="omfile"
File="/root/test.log"
)
stop
}
Reinicie rsyslog:
systemctl restart rsyslog
Instale el servicio de prueba:
# systemctl enable /root/test.service
Verifique la configuración del límite de tasa del servicio de prueba ( LogRateLimitIntervalSec
se almacena internamente como LogRateLimitIntervalUSec
):
# systemctl show --property LogRateLimitIntervalUSec test.service --no-pager
LogRateLimitIntervalUSec=0
# systemctl show --property LogRateLimitBurst test.service --no-pager
LogRateLimitBurst=0
Iniciar el servicio:
systemctl start test.service
Mi resultado:
- /root/test.log se detiene en
Hello world 12500
journalctl -u test.service --no-pager
se detiene enHello world 12500
- /var/log/messages informes (a veces este mensaje no se registra)
systemd-journald[304398]: Suppressed 982500 messages from test.service
También confirmé que cambiar la configuración global del diario (y reiniciar systemd-journald):
[Journal]
RateLimitIntervalSec=0
RateLimitBurst=0
no da como resultado ninguna limitación de velocidad como se esperaba.
No tengo ni idea a estas alturas. Incluso intenté analizar el código fuente de systemd, pero se me pasa por la cabeza. Si alguien al menos recreara mis pasos e informara los resultados, sería útil informar esto en el rastreador de problemas de systemd Github.
Gracias.
Respuesta1
La RateLimitIntervalSec=, RateLimitBurst=
sección en man journald.conf
dice:
Para desactivar cualquier tipo de limitación de velocidad, establezca cualquiera de los valores en 0.
Sin embargo, no puede encontrar esto en la LogRateLimitIntervalSec=, LogRateLimitBurst=
sección en man systemd.exec
. Con su test.service
puede verificar fácilmente que configurar esto en algo distinto 0
funciona como se esperaba.