diff --git a/deployment/puppet/osnailyfacter/manifests/atop.pp b/deployment/puppet/osnailyfacter/manifests/atop.pp index 27c6f81442..70776b700c 100644 --- a/deployment/puppet/osnailyfacter/manifests/atop.pp +++ b/deployment/puppet/osnailyfacter/manifests/atop.pp @@ -55,10 +55,11 @@ class osnailyfacter::atop ( } # This file is used for atop binary log rotations by (ana)cron - file { '/etc/logrotate.d/atop': + file { '/etc/cron.daily/atop_retention': owner => 'root', group => 'root', - mode => '0644', - content => template('osnailyfacter/atop_logrotate.conf.erb'), + mode => '0755', + content => template('osnailyfacter/atop_retention.erb'), } + } diff --git a/deployment/puppet/osnailyfacter/templates/atop_logrotate.conf.erb b/deployment/puppet/osnailyfacter/templates/atop_logrotate.conf.erb deleted file mode 100644 index 1e10f9a371..0000000000 --- a/deployment/puppet/osnailyfacter/templates/atop_logrotate.conf.erb +++ /dev/null @@ -1,35 +0,0 @@ -# managed by puppet - -"<%= @logpath %>/atop*" -{ -# This file is used for atop binary files rotation -# Will keep binary files for last <%= @rotate %> days instead of 30 days provided by atop -# Do not modify its settings if not sure - daily - rotate <%= @rotate %> - nocompress - nocreate - missingok - notifempty - dateext - sharedscripts - lastaction -<% if @osfamily == 'RedHat' -%> - /bin/find <%= @logpath %> -type f -name 'atop_*' -mtime +<%= @rotate %> -delete -<% elsif @osfamily == 'Debian' -%> - /usr/bin/find <%= @logpath %> -type f -name 'atop_*' -mtime +<%= @rotate %> -delete -<% else -%> - /bin/sh -c "find <%= @logpath %> -type f -name 'atop_*' -mtime +<%= @rotate %> -delete" -<% end -%> - /bin/ln -f -s <%= @logpath %>/atop_$(date +%Y%m%d) <%= @logpath %>/atop_current - endscript - postrotate -<% if @osfamily == 'RedHat' -%> - /sbin/service atop restart 2>&1 >/dev/null -<% elsif @osfamily == 'Debian' -%> - /usr/sbin/service atop restart 2>&1 >/dev/null -<% else -%> - /bin/sh -c "service atop restart 2>&1 >/dev/null" -<% end -%> - endscript -} diff --git a/deployment/puppet/osnailyfacter/templates/atop_retention.erb b/deployment/puppet/osnailyfacter/templates/atop_retention.erb new file mode 100644 index 0000000000..194f09f8dd --- /dev/null +++ b/deployment/puppet/osnailyfacter/templates/atop_retention.erb @@ -0,0 +1,11 @@ +#!/bin/bash +# Managed by puppet +# This file manages the atop binary files. It will keep binary files for last +# <%= @rotate %> days instead of 30 days provided by atop. +PATH=/sbin:/bin:/usr/sbin:/usr/bin + +# remove files older than <%= @rotate %> days +find <%= @logpath %> -type f -name 'atop_*' -mtime +<%= @rotate %> -delete + +# link current to todays file +ln -f -s <%= @logpath %>/atop_$(date +%Y%m%d) <%= @logpath %>/atop_current