fuel-library/deployment/puppet/osnailyfacter/templates/atop_retention.erb

19 lines
672 B
Plaintext

#!/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
# remove atop_current if it is a broken symlink
test -L <%= @logpath %>/atop_current -a ! -e <%= @logpath %>/atop_current && \
rm <%= @logpath %>/atop_current
# link current to most recent file if it exists
recent=$(find <%= @logpath %>/atop_* -type f | tail -1)
if [ -n "$recent" ]; then
ln -f -s "$recent" <%= @logpath %>/atop_current
fi