5 =head1 NAME $RCSfile: updateccstorage.pl,v $
15 Andrew DeFaria <Andrew@ClearSCM.com>
23 Mon Dec 13 09:13:27 EST 2010
27 $Date: 2011/06/16 15:12:50 $
33 Usage updateccstorage.pl: [-u|sage] [-ve|rbose] [-deb|ug]
34 [-view [<tag>|all]| -vob [<tag>|all]]
37 -u|sage: Displays usage
40 -deb|ug: Output debug messages
42 -view [<tag>|all] Update view storage (Default: all)
43 -vob [<tag>|all] Update vob storage (Default: all)
44 -region [<region>|all] Update region (Default: all)
48 This script will record the state of Clearcase storage
58 use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib";
70 my $VERSION = '$Revision: 1.29 $';
71 ($VERSION) = ($VERSION =~ /\$Revision: (.*) /);
73 my $clearadm = Clearadm->new;
75 # Given a view tag, snapshot the storage sizes
76 sub snapshotViewStorage($$) {
77 my ($tag, $region) = @_;
84 my $view = Clearcase::View->new($tag, $region);
86 $viewstorage{private} = $view->viewPrivateStorage;
87 $viewstorage{db} = $view->viewDatabase;
88 $viewstorage{admin} = $view->viewAdmin;
89 $viewstorage{total} = $view->viewSpace;
91 my ($err, $msg) = $clearadm->AddViewStorage(%viewstorage);
93 error $msg, $err if $err;
94 } # snapshotVobStorage
96 # Given a vob tag, snapshot the storage sizes
97 sub snapshotVobStorage($$) {
98 my ($tag, $region) = @_;
105 my $vob = Clearcase::Vob->new($tag, $region);
107 $vobstorage{admin} = $vob->admsize;
108 $vobstorage{db} = $vob->dbsize;
109 $vobstorage{cleartext} = $vob->ctsize;
110 $vobstorage{derivedobj} = $vob->dosize;
111 $vobstorage{source} = $vob->srcsize;
112 $vobstorage{total} = $vob->size;
114 my ($err, $msg) = $clearadm->AddVobStorage(%vobstorage);
116 error $msg, $err, if $err;
117 } # snapshotVobStorage
124 'usage' => sub { Usage },
125 'verbose' => sub { set_verbose },
126 'debug' => sub { set_debug },
130 ) or Usage "Invalid parameter";
132 Usage 'Extraneous options: ' . join ' ', @ARGV if @ARGV;
134 unless ($opts{view} or $opts{vob}) {
139 $opts{region} ||= 'all';
142 verbose "$FindBin::Script V$VERSION";
144 if ($opts{view} and $opts{view} =~ /all/i) {
145 if ($opts{region} =~ /all/i) {
146 for my $region ($Clearcase::CC->regions) {
147 my $views = Clearcase::Views->new($region);
149 for my $view ($views->views) {
150 verbose "Snapshotting view $view in region $region";
152 snapshotViewStorage $view, $region;
156 my $views = Clearcase::Views->new($opts{region});
158 for my $view ($views->views) {
159 verbose "Snapshotting view $view in region $opts{region}";
161 snapshotViewStorage $view, $opts{region};
164 } elsif ($opts{view}) {
165 if ($opts{region} =~ /all/i) {
166 for my $region ($Clearcase::CC->regions) {
167 verbose "Snapshotting view $opts{view} in region $region";
169 snapshotViewStorage $opts{view}, $region;
172 verbose "Snapshotting view $opts{view} in region $opts{region}";
174 snapshotViewStorage $opts{view}, $opts{region};
178 if ($opts{vob} and $opts{vob} =~ /all/i) {
179 if ($opts{region} =~ /all/i) {
180 for my $region ($Clearcase::CC->regions) {
181 my $vobs = Clearcase::Vobs->new(undef, $region);
183 for my $vob ($vobs->vobs) {
184 verbose "Snapshotting vob $vob in region $region";
186 snapshotVobStorage $vob, $region;
190 my $vobs = Clearcase::Vobs->new(undef, $opts{region});
192 for my $vob ($vobs->vobs) {
193 verbose "Snapshotting vob $vob in region $opts{region}";
195 snapshotVobStorage $vob, $opts{region};
198 } elsif ($opts{vob}) {
199 if ($opts{region} =~ /all/i) {
200 for my $region ($Clearcase::CC->regions) {
201 verbose "Snapshotting view $opts{vob} in region $region";
203 snapshotVobStorage $opts{vob}, $region;
206 verbose "Snapshotting vob $opts{vob} in region $opts{region}";
208 snapshotVobStorage $opts{vob}, $opts{region};
214 =head1 CONFIGURATION AND ENVIRONMENT
216 DEBUG: If set then $debug is set to this level.
218 VERBOSE: If set then $verbose is set to this level.
220 TRACE: If set then $trace is set to this level.
228 L<Getopt::Long|Getopt::Long>
230 L<Net::Domain|Net::Domain>
232 =head2 ClearSCM Perl Modules
247 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearadm.pm">Clearadm</a><br>
248 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearcase/Vobs.pm">Clearcase::Vobs</a><br>
249 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearcase/Vobs.pm">Clearcase::Vob</a><br>
250 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearcase/Views.pm">Clearcase::Views</a><br>
251 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearcase/View.pm">Clearcase::View</a><br>
252 <a href="http://clearscm.com/php/scm_man.php?file=lib/DateUtils.pm">DateUtils</a><br>
253 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
254 <a href="http://clearscm.com/php/scm_man.php?file=lib/Utils.pm">Utils</a><br>
259 =head1 BUGS AND LIMITATIONS
261 There are no known bugs in this script
263 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
265 =head1 LICENSE AND COPYRIGHT
267 Copyright (c) 2010, ClearSCM, Inc. All rights reserved.