Add script to static to gzip logs & rm >183d old
Add script and cron job to consolidate find through /srv/static/logs/ to gzip files and to search for .gz files over 183 days old and empty directories over a day old and remove them. Change-Id: I78f08852c8ee45fe8234d6b8ea0e25e199216cfd Reviewed-on: https://review.openstack.org/26049 Reviewed-by: Clark Boylan <clark.boylan@gmail.com> Reviewed-by: Monty Taylor <mordred@inaugust.com> Reviewed-by: James E. Blair <corvus@inaugust.com> Approved: James E. Blair <corvus@inaugust.com> Tested-by: Jenkins
This commit is contained in:
parent
9a368f19cd
commit
5128ee3457
11
modules/openstack_project/files/log_archive_maintenance.sh
Normal file
11
modules/openstack_project/files/log_archive_maintenance.sh
Normal file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
sleep $((RANDOM%600)) && \
|
||||
flock -n /var/run/gziplogs.lock \
|
||||
find /srv/static/logs/ -depth \
|
||||
\( \
|
||||
\( -type f -not -name robots.txt -not -name \*.gz \
|
||||
\( -name \*.txt -or -name \*.html -or -name tmp\* \) \
|
||||
-exec gzip \{\} \; \) \
|
||||
-o \( -type f -mtime +183 -name \*.gz -execdir rm \{\} \; \) \
|
||||
-o \( -type d -empty -mtime +1 -execdir rmdir {} \; \) \
|
||||
\)
|
@ -94,12 +94,21 @@ class openstack_project::static (
|
||||
require => File['/srv/static/logs'],
|
||||
}
|
||||
|
||||
cron { 'gziplogs':
|
||||
file { '/usr/local/sbin/log_archive_maintenance.sh':
|
||||
ensure => present,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0744',
|
||||
source => 'puppet:///modules/openstack_project/log_archive_maintenance.sh',
|
||||
}
|
||||
|
||||
cron { 'gziprmlogs':
|
||||
user => 'root',
|
||||
minute => '0',
|
||||
hour => '*/6',
|
||||
command => 'sleep $((RANDOM\%600)) && flock -n /var/run/gziplogs.lock find /srv/static/logs/ -type f -not -name robots.txt -not -name \*.gz \( -name \*.txt -or -name \*.html -or -name tmp\* \) -exec gzip \{\} \;',
|
||||
environment => 'PATH=/var/lib/gems/1.8/bin:/usr/bin:/bin:/usr/sbin:/sbin',
|
||||
command => 'bash /usr/local/sbin/log_archive_maintenance.sh',
|
||||
environment => 'PATH=/usr/bin:/bin:/usr/sbin:/sbin',
|
||||
require => File['/usr/local/sbin/log_archive_maintenance.sh'],
|
||||
}
|
||||
|
||||
###########################################################
|
||||
|
Loading…
x
Reference in New Issue
Block a user