Atraso de deslocamento logrotate do Linux

1

Eu tenho servidores com grande tamanho diário de arquivos de log ~ 1GB. Eu quero fazer logrotate diariamente à meia-noite. O problema é que cada arquivo girado está faltando 17 a 25 minutos após a meia-noite e o mesmo arquivo contém 17 a 25 minutos de dados para o dia seguinte.

Minha pergunta é como fazer o logrotate corretamente para cada dia e os dados desse dia devem ser da meia-noite à meia-noite.

O servidor tem alguns serviços e cada serviço tem um arquivo diário de 100MB-1,5GB como apache2, lighttpd, ftp, etc.

menos /var/log/lighttpd/access.log.1

np.domainexample.co.uk 11.22.33.44 - [16/Oct/2012:00:18:20 +0100] "GET /nowplaying/aim_abc.xml HTTP/1.1" 2422 200 "domainexample/1.3 CFNetwork/596.2.3 Darwin/12.2.0 (x86_64) (iMac9%2C1)" "-"
np.domainexample.co.uk 11.22.33.44 - [16/Oct/2012:00:18:20 +0100] "GET /nowplaying/aim_abc.xml HTTP/1.1" 2422 200 "domainexample/1.3 CFNetwork/596.2.3 Darwin/12.2.0 (x86_64) (iMac12%2C1)" "-"
np.domainexample.co.uk 11.22.33.44 - [16/Oct/2012:00:18:20 +0100] "GET /nowplaying/aim_abr.xml HTTP/1.1" 0 304 "hhh%20Radio%20Umee/616 CFNetwork/548.1.4 Darwin/11.0.0" "-"
np.domainexample.co.uk 11.22.33.44 - [16/Oct/2012:00:18:20 +0100] "GET /nowplaying/aim_abr.xml HTTP/1.1" 2433 200 "NobexRadio" "-"
np.domainexample.co.uk 11.22.33.44 - [16/Oct/2012:00:18:20 +0100] "GET /nowplaying/aim_abr.xml HTTP/1.1" 2433 200 "domainexample/1.3 CFNetwork/520.4.3 Darwin/11.4.0 (x86_64) (iMac11%2C2)" "-"

finalizar /var/log/lighttpd/access.log.1

np.domainexample.co.uk 11.22.33.44 - [17/Oct/2012:00:21:56 +0100] "GET /nowplaying/aim_abr.xml HTTP/1.1" 2121 200 "domainexample/1.3 CFNetwork/520.5.1 Darwin/11.4.2 (x86_64) (iMac12%2C2)" "-"
exam.as5623.net 11.22.33.44 - [17/Oct/2012:00:21:56 +0100] "GET /oconnell/20121012170055.mp3 HTTP/1.1" 78118 206 "AppleCoreMedia/1.0.0.10A403 (iPod; U; CPU OS 6_0 like Mac OS X; en_gb)" "-"
exam.as5623.net 11.22.33.44 - [17/Oct/2012:00:21:56 +0100] "GET /oconnell/20121001174703.mp3 HTTP/1.1" 78120 206 "AppleCoreMedia/1.0.0.10A403 (iPhone; U; CPU OS 6_0 like Mac OS X; en_us)" "-"
exam.as5623.net 11.22.33.44 - [17/Oct/2012:00:21:56 +0100] "GET /frankskinner/20120905121827.mp3 HTTP/1.1" 78117 206 "AppleCoreMedia/1.0.0.10A403 (iPhone; U; CPU OS 6_0 like Mac OS X; en_gb)" "-"
np.domainexample.co.uk 11.22.33.44 - [17/Oct/2012:00:21:56 +0100] "GET /nowplaying/aim_ab8.xml HTTP/1.1" 0 304 "hhh%2080s/616 CFNetwork/609 Darwin/13.0.0" "-"

bzless /var/log/lighttpd/access.log.2.bz2

exam.as5623.net 11.22.33.44 - [15/Oct/2012:00:17:03 +0100] "GET /dave_gorman/20121014130335.mp3 HTTP/1.1" 78117 206 "AppleCoreMedia/1.0.0.10A403 (iPhone; U; CPU OS 6_0 like Mac OS X; en_us)" "-"
np.domainexample.co.uk 11.22.33.44 - [15/Oct/2012:00:17:03 +0100] "GET /nowplaying/aim_ab8.xml HTTP/1.1" 2190 200 "hhh/1 CFNetwork/520.4.3 Darwin/11.4.0 (x86_64) (iMac12%2C1)" "-"
exam.as5623.net 11.22.33.44 - [15/Oct/2012:00:17:03 +0100] "GET /frankskinner/20121013132200.mp3 HTTP/1.1" 284941 206 "AppleCoreMedia/1.0.0.10A403 (iPhone; U; CPU OS 6_0 like Mac OS X; en_gb)" "-"
exam.as5623.net 11.22.33.44 - [15/Oct/2012:00:17:03 +0100] "GET /dave_gorman/20121014130335.mp3 HTTP/1.1" 78117 206 "AppleCoreMedia/1.0.0.10A403 (iPhone; U; CPU OS 6_0 like Mac OS X; en_us)" "-"
exam.as5623.net 11.22.33.44 - [15/Oct/2012:00:17:03 +0100] "GET /dave_gorman/20121014130335.mp3 HTTP/1.1" 78117 206 "AppleCoreMedia/1.0.0.10A403 (iPhone; U; CPU OS 6_0 like Mac OS X; en_us)" "-"

bztail /var/log/lighttpd/access.log.2.bz2

np.domainexample.co.uk 11.22.33.44 - [16/Oct/2012:00:18:20 +0100] "GET /nowplaying/aim_abr.xml HTTP/1.1" 2433 200 "hhh/1.3 CFNetwork/454.12.4 Darwin/10.8.0 (i386) (MacBookPro5%2C5)" "-"
exam.as5623.net 11.22.33.44 - [16/Oct/2012:00:18:20 +0100] "GET /dave_gorman/20121014130335.mp3 HTTP/1.1" 41486 206 "AppleCoreMedia/1.0.0.10A403 (iPod; U; CPU OS 6_0 like Mac OS X; en_gb)" "-"
exam.as5623.net 11.22.33.44 - [16/Oct/2012:00:18:20 +0100] "GET /frankskinner/20121013132200.mp3 HTTP/1.1" 78377 206 "AppleCoreMedia/1.0.0.10A403 (iPhone; U; CPU OS 6_0 like Mac OS X; en_gb)" "-"
np.domainexample.co.uk 11.22.33.44 - [16/Oct/2012:00:18:20 +0100] "GET /nowplaying/aim_abc.xml HTTP/1.1" 0 304 "Classic%20Rock/616 CFNetwork/609 Darwin/13.0.0" "-"

bzless /var/log/lighttpd/access.log.3.bz2

np.domainexample.co.uk 11.22.33.44 - [14/Oct/2012:00:19:03 +0100] "GET /nowplaying/aim_ab0.xml HTTP/1.1" 0 304 "hhh%2080s/616 CFNetwork/609 Darwin/13.0.0" "-"
exam.as5623.net 11.22.33.44 - [14/Oct/2012:00:19:03 +0100] "GET /oconnell/20120920182425.mp3 HTTP/1.1" 78118 206 "AppleCoreMedia/1.0.0.10A403 (iPhone; U; CPU OS 6_0 like Mac OS X; en_us)" "-"
np.domainexample.co.uk 11.22.33.44 - [14/Oct/2012:00:19:03 +0100] "GET /nowplaying/aim_ab0.xml HTTP/1.1" 0 304 "hhh%2080s/616 CFNetwork/548.1.4 Darwin/11.0.0" "-"
np.domainexample.co.uk 11.22.33.44 - [14/Oct/2012:00:19:03 +0100] "GET /nowplaying/aim_abc.xml HTTP/1.1" 0 304 "hhh%20Radio%20Umee/616 CFNetwork/609 Darwin/13.0.0" "-"
np.domainexample.co.uk 11.22.33.44 - [14/Oct/2012:00:19:03 +0100] "GET /nowplaying/aim_ab9.xml HTTP/1.1" 0 304 "hhh%20Radio%20Umee/616 CFNetwork/548.1.4 Darwin/11.0.0" "-"

bztail /var/log/lighttpd/access.log.3.bz2

np.domainexample.co.uk 11.22.33.44 - [15/Oct/2012:00:17:02 +0100] "GET /nowplaying/ab7.xml HTTP/1.1" 1295 200 "PHP/5.2.6" "-"
np.domainexample.co.uk 11.22.33.44 - [15/Oct/2012:00:17:02 +0100] "GET /tracks/7869.xml HTTP/1.1" 1998 200 "PHP/5.2.6" "-"
exam.as5623.net 11.22.33.44 - [15/Oct/2012:00:17:02 +0100] "GET /frankskinner/20121013132200.mp3 HTTP/1.1" 230649 206 "AppleCoreMedia/1.0.0.10A403 (iPhone; U; CPU OS 6_0 like Mac OS X; en_gb)" "-"
exam.as5623.11.22.33.44 - [15/Oct/2012:00:17:02 +0100] "GET /frankskinner/20121013132200.mp3 HTTP/1.1" 78377 206 "AppleCoreMedia/1.0.0.10A403 (iPad; U; CPU OS 6_0 like Mac OS X; en_us)" "-"
np.domainexample.co.uk 11.22.33.44 - [15/Oct/2012:00:17:02 +0100] "GET /nowplaying/abx.xml HTTP/1.1" 314 200 "PHP/5.2.6" "-"

cat /etc/logrotate.d/lighttpd

/var/log/lighttpd/*.log {
    daily
   missingok
   rotate 999
   compresscmd /bin/bzip2
   compressext .bz2
   compress
   delaycompress
   notifempty
   copytruncate
   sharedscripts
   postrotate
      if [ -f /var/run/lighttpd.pid ]; then \
        if [ -x /usr/sbin/invoke-rc.d ]; then \
           invoke-rc.d lighttpd force-reload > /dev/null; \
        else \
           /etc/init.d/lighttpd force-reload > /dev/null; \
        fi; \
      fi;
   endscript
}

ls /etc/logrotate.d /

apache2
apt
aptitude
dpkg
lighttpd
ocsinventory-agent
ppp
rsyslog.disabled
syslog-ng
vsftpd

Felicidades,

E

    
por Lihnjo 17.10.2012 / 15:46

1 resposta

0

Você realmente precisa da meia-noite à meia-noite sem qualquer entrada no registro do dia anterior / seguinte?

Depois, você precisa fazer o pós-processamento dos arquivos de log em que você corta e não cola seus logs mais antigos nas bordas direitas.

Se você pudesse avaliar melhor a execução do seu logrotation, você está sempre correndo em condições de corrida entre girar todos os arquivos de log e usuários acessando seus servidores ao mesmo tempo, então para arquivos de log perfeitos de um dia você precisa de pós-processamento. .

    
por 18.10.2012 / 09:18