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
54 use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib";
62 my $VERSION = '$Revision: 1.9 $';
63 ($VERSION) = ($VERSION =~ /\$Revision: (.*) /);
65 my $clearadm = Clearadm->new;
71 'usage' => sub { Usage },
72 'verbose' => sub { set_verbose },
73 'debug' => sub { set_debug },
74 ) or Usage "Invalid parameter";
76 Usage 'Extraneous options: ' . join ' ', @ARGV
80 verbose "$FindBin::Script V$VERSION";
84 for my $system ($clearadm->FindSystem ($host)) {
85 ($err, $msg) = $clearadm->TrimLoadavg ($$system{name});
87 if ($msg eq 'Records deleted' or $msg eq '') {
88 verbose "Scrub loadavg $$system{name}: $err $msg:";
93 for my $filesystem ($clearadm->FindFilesystem ($$system{name}, $fs)) {
94 ($err, $msg) = $clearadm->TrimFS ($$system{name}, $$filesystem{filesystem});
96 if ($msg eq 'Records deleted' or $msg eq '') {
97 verbose "Scrub filesystem $$system{name}:$$filesystem{filesystem}: $err $msg";
104 # TODO: These should be configurable
105 my $sixMonthsAgo = SubtractDays (Today2SQLDatetime, 180);
109 started => Today2SQLDatetime,
110 system => hostname(),
113 # Scrub old alertlogs
114 ($runlog{status}, $runlog{message}) =
115 $clearadm->DeleteAlertlog ("timestamp<='$sixMonthsAgo'");
117 verbose "$runlog{task} alertlog: $runlog{status} $runlog{message}";
119 $clearadm->AddRunlog (%runlog);
121 $runlog{started} = Today2SQLDatetime;
124 ($runlog{status}, $runlog{message}) =
125 $clearadm->DeleteRunlog ("started<='$sixMonthsAgo'");
127 verbose "$runlog{task} runlog: $runlog{status} $runlog{message}";
129 $clearadm->AddRunlog (%runlog);
133 =head1 CONFIGURATION AND ENVIRONMENT
135 DEBUG: If set then $debug is set to this level.
137 VERBOSE: If set then $verbose is set to this level.
139 TRACE: If set then $trace is set to this level.
147 L<Getopt::Long|Getopt::Long>
149 =head2 ClearSCM Perl Modules
164 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearadm.pm">Clearadm</a><br>
165 <a href="http://clearscm.com/php/scm_man.php?file=lib/DateUtils.pm">DateUtils</a><br>
166 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
167 <a href="http://clearscm.com/php/scm_man.php?file=lib/TimeUtils.pm">TimeUtils</a><br>
168 <a href="http://clearscm.com/php/scm_man.php?file=lib/Utils.pm">Utils</a><br>
173 =head1 BUGS AND LIMITATIONS
175 There are no known bugs in this script
177 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
179 =head1 LICENSE AND COPYRIGHT
181 Copyright (c) 2010, ClearSCM, Inc. All rights reserved.