5 =head1 NAME $RCSfile: clearadmscrub.pl,v $
15 Andrew DeFaria <Andrew@ClearSCM.com>
23 Sun Jan 2 19:40:28 EST 2011
27 $Date: 2012/11/09 06:45:36 $
33 Usage clearadmscrub.pl: [-u|sage] [-ve|rbose] [-deb|ug]
36 -u|sage: Displays usage
39 -deb|ug: Output debug messages
43 This script will scrub all old records in the Clearadm database
53 use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib";
61 my $VERSION = '$Revision: 1.9 $';
62 ($VERSION) = ($VERSION =~ /\$Revision: (.*) /);
64 my $clearadm = Clearadm->new;
70 'usage' => sub { Usage },
71 'verbose' => sub { set_verbose },
72 'debug' => sub { set_debug },
73 ) or Usage "Invalid parameter";
75 Usage 'Extraneous options: ' . join ' ', @ARGV
79 verbose "$FindBin::Script V$VERSION";
83 foreach my $system ($clearadm->FindSystem ($host)) {
84 ($err, $msg) = $clearadm->TrimLoadavg ($$system{name});
86 if ($msg eq 'Records deleted' or $msg eq '') {
87 verbose "Scrub loadavg $$system{name}: $err $msg:";
92 foreach my $filesystem ($clearadm->FindFilesystem ($$system{name}, $fs)) {
93 ($err, $msg) = $clearadm->TrimFS ($$system{name}, $$filesystem{filesystem});
95 if ($msg eq 'Records deleted' or $msg eq '') {
96 verbose "Scrub filesystem $$system{name}:$$filesystem{filesystem}: $err $msg";
103 # TODO: These should be configurable
104 my $sixMonthsAgo = SubtractDays (Today2SQLDatetime, 180);
108 started => Today2SQLDatetime,
111 # Scrub old alertlogs
112 ($runlog{status}, $runlog{message}) =
113 $clearadm->DeleteAlertlog ("timestamp<='$sixMonthsAgo'");
115 verbose "$runlog{task} alertlog: $runlog{status} $runlog{message}";
117 $clearadm->AddRunlog (%runlog);
119 $runlog{started} = Today2SQLDatetime;
122 ($runlog{status}, $runlog{message}) =
123 $clearadm->DeleteRunlog ("started<='$sixMonthsAgo'");
125 verbose "$runlog{task} runlog: $runlog{status} $runlog{message}";
127 $clearadm->AddRunlog (%runlog);
131 =head1 CONFIGURATION AND ENVIRONMENT
133 DEBUG: If set then $debug is set to this level.
135 VERBOSE: If set then $verbose is set to this level.
137 TRACE: If set then $trace is set to this level.
145 L<Getopt::Long|Getopt::Long>
147 =head2 ClearSCM Perl Modules
162 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearadm.pm">Clearadm</a><br>
163 <a href="http://clearscm.com/php/scm_man.php?file=lib/DateUtils.pm">DateUtils</a><br>
164 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
165 <a href="http://clearscm.com/php/scm_man.php?file=lib/TimeUtils.pm">TimeUtils</a><br>
166 <a href="http://clearscm.com/php/scm_man.php?file=lib/Utils.pm">Utils</a><br>
171 =head1 BUGS AND LIMITATIONS
173 There are no known bugs in this script
175 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
177 =head1 LICENSE AND COPYRIGHT
179 Copyright (c) 2010, ClearSCM, Inc. All rights reserved.