On Fri, Aug 28, 2009 at 03:41:53PM +0200, Michael Hanselmann wrote: > > --- > .gitignore | 3 +++ > Makefile.am | 10 ++++++++++ > daemons/ganeti-job-archive.in | 40 ++++++++++++++++++++++++++++++++++++++++ > doc/examples/ganeti.cron.in | 4 +++- > 4 files changed, 56 insertions(+), 1 deletions(-) > create mode 100755 daemons/ganeti-job-archive.in > > diff --git a/.gitignore b/.gitignore > index 6a059c0..6a0647a 100644 > --- a/.gitignore > +++ b/.gitignore > @@ -27,6 +27,9 @@ > /*.tar.bz2 > /*.tar.gz > > +# daemons > +/daemons/ganeti-job-archive
Might I suggest ganeti-cleaner as maybe in the future other things need cleanup? > + > # devel > /devel/clean-cluster > /devel/upload > diff --git a/Makefile.am b/Makefile.am > index cda2181..116e097 100644 > --- a/Makefile.am > +++ b/Makefile.am > @@ -45,6 +45,7 @@ MAINTAINERCLEANFILES = \ > > CLEANFILES = \ > autotools/replace_vars.sed \ > + daemons/ganeti-job-archive \ > devel/upload \ > doc/rapi-resources.gen \ > doc/examples/bash_completion \ > @@ -139,6 +140,9 @@ dist_sbin_SCRIPTS = \ > scripts/gnt-node \ > scripts/gnt-os > > +nodist_sbin_SCRIPTS = \ > + daemons/ganeti-job-archive > + > dist_tools_SCRIPTS = \ > tools/burnin \ > tools/cfgshell \ > @@ -151,6 +155,7 @@ EXTRA_DIST = \ > DEVNOTES \ > pylintrc \ > autotools/docbook-wrapper \ > + daemons/ganeti-job-archive.in \ > devel/upload.in \ > $(docrst) \ > $(docdot) \ > @@ -243,6 +248,11 @@ doc/examples/%: doc/examples/%.in stamp-directories \ > $(REPLACE_VARS_SED) > sed -f $(REPLACE_VARS_SED) < $< > $@ > > +daemons/ganeti-job-archive: daemons/ganeti-job-archive.in stamp-directories \ > + $(REPLACE_VARS_SED) > + sed -f $(REPLACE_VARS_SED) < $< > $@ > + chmod +x $@ > + > doc/%.html: doc/%.rst > @test -n "$(RST2HTML)" || { echo 'rst2html' not found during configure; > exit 1; } > $(RST2HTML) $< $@ > diff --git a/daemons/ganeti-job-archive.in b/daemons/ganeti-job-archive.in > new file mode 100755 > index 0000000..a3cd7e5 > --- /dev/null > +++ b/daemons/ganeti-job-archive.in > @@ -0,0 +1,40 @@ > +#!/bin/bash > +# > + > +# Copyright (C) 2009 Google Inc. > +# > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 2 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, but > +# WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > +# General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program; if not, write to the Free Software > +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA > +# 02110-1301, USA. > + > +set -e > + > +data_d...@localstatedir@/lib/ganeti > +QUEUE_ARCHIVE_DIR=$DATA_DIR/queue/archive > + > +# Define how many minutes archived jobs should be left alone (21 days by > +# default) > +REMOVE_AFTER=$(( 21 * 24 * 60 )) > + > +# Exit if machine is not part of a cluster > +[[ -e $DATA_DIR/ssconf_master_node ]] || echo 0 > + > +# Exit if queue archive directory doesn't exist > +[[ -d $QUEUE_ARCHIVE_DIR ]] || exit 0 > + > +# Remove old jobs > +find $QUEUE_ARCHIVE_DIR -mindepth 2 -type f -mmin +$REMOVE_AFTER -print0 | \ > +xargs -0 rm -f add "-r". another option is find -delete. replace mmin with mtime, so that you simply say REMOVE_AFTER=21. > + > +exit 0 > diff --git a/doc/examples/ganeti.cron.in b/doc/examples/ganeti.cron.in > index 155411a..0faf4a6 100644 > --- a/doc/examples/ganeti.cron.in > +++ b/doc/examples/ganeti.cron.in > @@ -1,3 +1,5 @@ > PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin > -# restart failed instances > +# Restart failed instances (every 5 minutes) > */5 * * * * root [ -x @SBINDIR@/ganeti-watcher ] && @SBINDIR@/ganeti-watcher add a newline here. > +# Compress job archive (at 01:45 AM) > +45 1 * * * root [ -x @SBINDIR@/ganeti-job-archive ] && > @SBINDIR@/ganeti-job-archive iustin