forked from sodabrew/puppet-dashboard
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request sodabrew#106 from Whopper92/cleanup_dashboard_cron
(#11849) Add rake task to install cron job to clean up database reports
- Loading branch information
Showing
4 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
# Example script to clean up after Dashboard by pruning old reports. | ||
# Options for the rake task specifying time requirements for report | ||
# deletion can be modified in this script. As specified below, this task will | ||
# delete reports older than one month. To view options for the task, | ||
# run `rake reports:prune` in the directory containing puppet-dashboard's | ||
# code. | ||
|
||
set -u | ||
|
||
PUPPET_DB_PATH=/usr/share/puppet-dashboard | ||
|
||
output=`rake -s -f ${PUPPET_DB_PATH}/Rakefile RAILS_ENV=production reports:prune upto=1 unit=mon 2>&1 1> /dev/null` | ||
if [ $? -ne 0 ]; then | ||
logger -i "${output}" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require 'fileutils' | ||
namespace :cron do | ||
desc 'Install monthly cron job to automatically prune old reports from the databases.' | ||
task :cleanup do | ||
cron_path = '/etc/cron.monthly' | ||
dashboard_path = '/usr/share/puppet-dashboard/examples' | ||
cron_script = 'puppet-dashboard.cleanup_reports.cron' | ||
|
||
begin | ||
ln_sf("#{dashboard_path}/#{cron_script}", "#{cron_path}/#{cron_script}") | ||
rescue | ||
puts "\n\nError: Could not create symlink #{cron_path}/#{cron_script}\n" | ||
puts "Are you root?\n" | ||
end | ||
end | ||
end |