From 95a6dc7cc7888ceaee49fbff70c36ef99b7bf20e Mon Sep 17 00:00:00 2001 From: Alex Schultz Date: Mon, 4 May 2015 10:54:38 -0500 Subject: [PATCH] Remove atop logrotate configuration The previous logrotate configuration was improperly rotating the log file which is not necessary due to the daily restart of atop. The binary retention is now handled via a new atop retention cron. This change removes the atop logrotate configuration. Change-Id: I76e3c12b46946ed7c48719f51e953528708c2d4b Closes-Bug: 1452389 --- .../puppet/osnailyfacter/manifests/atop.pp | 7 ++-- .../templates/atop_logrotate.conf.erb | 35 ------------------- .../templates/atop_retention.erb | 11 ++++++ 3 files changed, 15 insertions(+), 38 deletions(-) delete mode 100644 deployment/puppet/osnailyfacter/templates/atop_logrotate.conf.erb create mode 100644 deployment/puppet/osnailyfacter/templates/atop_retention.erb 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