Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Purging of old log files #9

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
30 changes: 30 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -19,12 +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,
$daily_restarts = $atop::params::daily_restarts
) inherits atop::params {
$service_state = $service ? {
true => 'running',
Expand All @@ -45,6 +56,25 @@
ensure => $service_state,
enable => $service,
}
if ($keepdays != undef and $::osfamily != 'Archlinux') {
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
}
}
if ($daily_restarts) {
file {
'/etc/cron.d/atop':
content => "0 0 * * * root systemctl try-restart atop\n"
}
}
}

# vim: set et sw=2:
17 changes: 13 additions & 4 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,26 @@
$service = false
$interval = 600
$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.'),
}
$daily_restarts = $::osfamily ? {
'RedHat' => true,
default => false
}
$conf_file_owner = 'root'
$conf_file_group = 'root'
$conf_file_mode = '0644'
$conf_file_template = $::osfamily ? {
/Debian|RedHat/ => "atop/atop-${::osfamily}.erb",
default => fail('Unsupported Operating System.'),
if ($facts.get('systemd', true)) {
$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:
5 changes: 5 additions & 0 deletions templates/atop-Archlinux.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
LOGPATH="<%= @logpath %>"
LOGINTERVAL="<%= @interval %>"
<%- if @keepdays -%>
LOGGENERATIONS="<%= @keepdays %>"
<%- end -%>
3 changes: 3 additions & 0 deletions templates/atop-RedHat.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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