From 755028c7e06a389c51eddf33d15840806f71afbc Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Mon, 20 Feb 2017 21:41:08 +0100 Subject: [PATCH 01/13] remove old logs --- manifests/init.pp | 14 ++++++++++++++ manifests/params.pp | 1 + 2 files changed, 15 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index 6921257..586dbc1 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -25,6 +25,7 @@ $service = $atop::params::service, $interval = $atop::params::interval, $logpath = $atop::params::logpath, + $keepdays = $atop::params::keepdays ) inherits atop::params { $service_state = $service ? { true => 'running', @@ -45,6 +46,19 @@ ensure => $service_state, enable => $service, } + if (defined $keepdays) { + cron { + 'remove_atop': + hour => '21', + minute => '13', + command => "/usr/bin/find ${logpath} -maxdepth 1 -mount -name atop_20* -mtime +${keepdays} -delete", + user => 'root'; + } + file { + '/etc/logrotate.d/atop': + ensure => absent + } + } } # vim: set et sw=2: diff --git a/manifests/params.pp b/manifests/params.pp index 2147ec9..96fc3bd 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -7,6 +7,7 @@ $service = false $interval = 600 $logpath = '/var/log/atop' + $keepdays = undef $conf_file = $::osfamily ? { 'Debian' => '/etc/default/atop', 'RedHat' => '/etc/sysconfig/atop', From a4b2173643e796cd13d56587f20a0249c3e40fdf Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Mon, 20 Feb 2017 23:32:25 +0100 Subject: [PATCH 02/13] bugfix --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 586dbc1..7348823 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -46,7 +46,7 @@ ensure => $service_state, enable => $service, } - if (defined $keepdays) { + if ($keepdays != undef) { cron { 'remove_atop': hour => '21', From 967b629b006fbca1db5583381d80c322fd414f3b Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Mon, 1 Jul 2019 15:29:02 +0200 Subject: [PATCH 03/13] support for Archlinux --- manifests/params.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index 96fc3bd..1c6aa5c 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -9,7 +9,7 @@ $logpath = '/var/log/atop' $keepdays = undef $conf_file = $::osfamily ? { - 'Debian' => '/etc/default/atop', + 'Debian|Archlinux' => '/etc/default/atop', 'RedHat' => '/etc/sysconfig/atop', default => fail('Unsupported Operating System.'), } @@ -17,7 +17,7 @@ $conf_file_group = 'root' $conf_file_mode = '0644' $conf_file_template = $::osfamily ? { - /Debian|RedHat/ => "atop/atop-${::osfamily}.erb", + /Debian|RedHat|Archlinux/ => "atop/atop-${::osfamily}.erb", default => fail('Unsupported Operating System.'), } } From 386867940355f43d51f8e1f9de0d512921a20a77 Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Mon, 1 Jul 2019 15:40:37 +0200 Subject: [PATCH 04/13] bugfix --- manifests/params.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index 1c6aa5c..aa1db3e 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -9,7 +9,7 @@ $logpath = '/var/log/atop' $keepdays = undef $conf_file = $::osfamily ? { - 'Debian|Archlinux' => '/etc/default/atop', + /Debian|Archlinux/ => '/etc/default/atop', 'RedHat' => '/etc/sysconfig/atop', default => fail('Unsupported Operating System.'), } From a0caafb388b8372eab37988b0d6516d01dba850d Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Mon, 1 Jul 2019 15:51:23 +0200 Subject: [PATCH 05/13] bugfix --- manifests/init.pp | 2 +- templates/atop-Archlinux | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 templates/atop-Archlinux diff --git a/manifests/init.pp b/manifests/init.pp index 7348823..4a848aa 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -46,7 +46,7 @@ ensure => $service_state, enable => $service, } - if ($keepdays != undef) { + if ($keepdays != undef and $::osfamily != 'Archlinux') { cron { 'remove_atop': hour => '21', diff --git a/templates/atop-Archlinux b/templates/atop-Archlinux new file mode 100644 index 0000000..cca5a9d --- /dev/null +++ b/templates/atop-Archlinux @@ -0,0 +1,5 @@ +LOGPATH="<%= @logpath %>" +LOGINTERVAL="<%= @interval %>" +<%- if @keepdays -%> +LOGGENERATIONS="<%= @keepdays %>" +<%- end -%> From 9974cc258688d21bbd9b64e5ececc7f43c883454 Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Tue, 2 Jul 2019 10:27:31 +0200 Subject: [PATCH 06/13] bugfix --- templates/{atop-Archlinux => atop-Archlinux.erb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename templates/{atop-Archlinux => atop-Archlinux.erb} (100%) diff --git a/templates/atop-Archlinux b/templates/atop-Archlinux.erb similarity index 100% rename from templates/atop-Archlinux rename to templates/atop-Archlinux.erb From 93ca34dfa83783bb0481a104e89b72491bcb5c29 Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Tue, 28 Apr 2020 14:01:49 +0200 Subject: [PATCH 07/13] seems like the Archlinux template is valid for all newer versions of atop running under systemd on all distributions --- manifests/params.pp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index aa1db3e..6c99339 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -16,9 +16,12 @@ $conf_file_owner = 'root' $conf_file_group = 'root' $conf_file_mode = '0644' - $conf_file_template = $::osfamily ? { - /Debian|RedHat|Archlinux/ => "atop/atop-${::osfamily}.erb", - default => fail('Unsupported Operating System.'), + if (::systemd) { + $conf_file_template = "atop/atop-Archlinux.erb" + } else { + $conf_file_template = $::osfamily ? { + /Debian|RedHat|Archlinux/ => "atop/atop-${::osfamily}.erb", + default => fail('Unsupported Operating System.'), } } # vim: set et sw=2: From f51e43e397ea7f018363b7a1087f30eb045ad96f Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Tue, 28 Apr 2020 14:30:32 +0200 Subject: [PATCH 08/13] bugfix --- manifests/params.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/manifests/params.pp b/manifests/params.pp index 6c99339..5f081bb 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -22,6 +22,7 @@ $conf_file_template = $::osfamily ? { /Debian|RedHat|Archlinux/ => "atop/atop-${::osfamily}.erb", default => fail('Unsupported Operating System.'), + } } } # vim: set et sw=2: From c8e64e24d9fff1b7b9825d3110614fa90acffcb9 Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Tue, 6 Apr 2021 09:11:43 +0200 Subject: [PATCH 09/13] some versions of atop on EL7 doesn't do the daily rotation right. workaround. --- README.md | 11 ++++++++--- manifests/init.pp | 18 +++++++++++++++++- manifests/params.pp | 6 +++++- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a74d26d..b8b9bdf 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,21 @@ puppet-atop =========== -[![Puppet Forge](http://img.shields.io/puppetforge/v/gnubilafrance/atop.svg)](https://forge.puppetlabs.com/gnubilafrance/atop) -[![Build Status](https://travis-ci.org/gnubila-france/puppet-atop.png?branch=master)](https://travis-ci.org/gnubila-france/puppet-atop) - Puppet module for managing atop. +Project home https://github.com/tobixen/puppet-atop + +This is a fork of https://github.com/gnubila-france/puppet-atop which seems not to be maintained + +This module has only been tested in a specific environment and may have unmapped dependencies, i.e. cron is used rather than systemd timers. The HEAD version has only been tested towards SL7 and Bionic. + Tested under: * Scientific Linux 5 * Scientific Linux 6 * CentOS 6 +* Ubuntu Bionic * Debian Wheezy +* Archlinux ## Usage diff --git a/manifests/init.pp b/manifests/init.pp index 4a848aa..ca0feea 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,3 +1,7 @@ +## This puppet module lives on https://github.com/tobixen/puppet-atop +## - it's a fork of https://github.com/gnubila-france/puppet-atop +## which seems not to be maintained anymore + # == Class: atop # # Allow to install and configure atop. @@ -19,13 +23,19 @@ # [*logpath*] # Directory were the log will be saved by the service. # Default is /var/log/atop. +# +# [*daily_restarts*] +# The puppet module should try to enforce daily restarts +# (defaults to "on" for EL, possible bug in atop +# package) class atop ( $package_name = $atop::params::package_name, $service_name = $atop::params::service_name, $service = $atop::params::service, $interval = $atop::params::interval, $logpath = $atop::params::logpath, - $keepdays = $atop::params::keepdays + $keepdays = $atop::params::keepdays, + $daily_restarts = $atop::params::daily_restarts ) inherits atop::params { $service_state = $service ? { true => 'running', @@ -59,6 +69,12 @@ ensure => absent } } + if ($daily_restarts) { + file { + '/etc/cron.d/atop': + content => '0 0 * * * root systemctl try-restart atop' + } + } } # vim: set et sw=2: diff --git a/manifests/params.pp b/manifests/params.pp index 5f081bb..dac1305 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -13,10 +13,14 @@ 'RedHat' => '/etc/sysconfig/atop', default => fail('Unsupported Operating System.'), } + $daily_restart = $::osfamily ? { + 'RedHat' => true, + default => false + } $conf_file_owner = 'root' $conf_file_group = 'root' $conf_file_mode = '0644' - if (::systemd) { + if ($::systemd) { $conf_file_template = "atop/atop-Archlinux.erb" } else { $conf_file_template = $::osfamily ? { From 0f33bc195d4bdfd908e3d3cb928cc30003ace67d Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Tue, 6 Apr 2021 10:02:25 +0200 Subject: [PATCH 10/13] fixup! some versions of atop on EL7 doesn't do the daily rotation right. workaround. --- manifests/params.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index dac1305..21cc691 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -13,7 +13,7 @@ 'RedHat' => '/etc/sysconfig/atop', default => fail('Unsupported Operating System.'), } - $daily_restart = $::osfamily ? { + $daily_restarts = $::osfamily ? { 'RedHat' => true, default => false } From 6fc8687981923b92d24f06d626f8f50ec68c79ad Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Tue, 4 May 2021 11:59:35 +0200 Subject: [PATCH 11/13] potential bugfix for atop logrotation and release of accounting file --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index ca0feea..875a34a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -72,7 +72,7 @@ if ($daily_restarts) { file { '/etc/cron.d/atop': - content => '0 0 * * * root systemctl try-restart atop' + content => '0 0 * * * root systemctl try-restart atop\n' } } } From 62a1f93f5f4776a1f9ba1d393e479b1a6e3627b7 Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Tue, 4 May 2021 12:04:13 +0200 Subject: [PATCH 12/13] fixup! potential bugfix for atop logrotation and release of accounting file --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 875a34a..f1612ee 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -72,7 +72,7 @@ if ($daily_restarts) { file { '/etc/cron.d/atop': - content => '0 0 * * * root systemctl try-restart atop\n' + content => "0 0 * * * root systemctl try-restart atop\n" } } } From 55a81f6ef331de59b486d16ccd8166f9543a145a Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Wed, 16 Feb 2022 12:57:06 +0100 Subject: [PATCH 13/13] the systemd fact may not be present everywhere. Defaulting it to true, as most modern systems have systemd --- manifests/params.pp | 2 +- templates/atop-RedHat.erb | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index 21cc691..19f1e01 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -20,7 +20,7 @@ $conf_file_owner = 'root' $conf_file_group = 'root' $conf_file_mode = '0644' - if ($::systemd) { + if ($facts.get('systemd', true)) { $conf_file_template = "atop/atop-Archlinux.erb" } else { $conf_file_template = $::osfamily ? { diff --git a/templates/atop-RedHat.erb b/templates/atop-RedHat.erb index ef63822..4e9edf8 100644 --- a/templates/atop-RedHat.erb +++ b/templates/atop-RedHat.erb @@ -13,3 +13,6 @@ BINPATH=/usr/bin PIDFILE=/var/run/atop.pid # interval (default 10 minutes) INTERVAL=<%= @interval %> + +# Hmm ... on EL7 it seems like the script expects LOGINTERVAL, not just INTERVAL +LOGINTERVAL=INTERVAL