5 =head1 NAME $RCSfile: plotstorage.cgi,v $
7 Plot Clearcse Storage usage
15 Andrew DeFaria <Andrew@ClearSCM.com>
23 Mon Dec 13 09:13:27 EST 2010
27 $Date: 2011/01/14 16:37:04 $
33 Usage plotstorage.cgi: tag=<tag> type=<vob|view> storage=<storage>
34 [height=<height>] [width=<width>] [color=<color>]
35 [scaling=<scaling>] [points=<points>] [tiny=<0|1>]
38 <tag>: Tag of the Clearcase object (vob or view)
39 <type>: Designates whether <tag> is a vob of a view
40 <storage>: Name of the Clearcase storage pool to plot information for
41 <height>: Height of chart (Default: 480px - tiny: 40)
42 <width>: Width of chart (Default: 800px - tiny: 150)
43 <color>: A GD::Color color value (Default: purple)
44 <scaling>: Currently one of Minute, Hour, Day or Month. Specifies how
45 Clearadm::GetFS will scale the data returned (Default: Minute
47 <points>: Number of points to plot (Default: all points - tiny: 7)
51 Draws a chart of the storage usage for the Clearcase object (vob|view).
52 Parameters such as height, width, color, scaling and points can be set
53 individually though more often the user will just use the web controls to set
54 them. Defaults produce a nice chart. Tiny mode is used by
55 <vob|view>details.cgi to draw tiny charts in the table. Setting tiny sets
56 a number of the other chart options to produce a standard, tiny chart.
66 use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib";
73 use CGI qw(:standard :cgi-lib);
78 my $VERSION = '$Revision: 1.13 $';
79 ($VERSION) = ($VERSION =~ /\$Revision: (.*) /);
81 $opts{color} ||= $opts{type} eq 'vob' ? 'purple' : 'marine';
82 $opts{height} ||= 350;
89 $opts{scaling} = 'Day';
92 my $clearadm = Clearadm->new;
94 my $graph = GD::Graph::area->new($opts{width}, $opts{height});
96 graphError "Tag is required" unless $opts{tag};
97 graphError "Type is required" unless $opts{type};
98 graphError "Storage is required" unless $opts{storage};
100 graphError "Points not numeric (points: $opts{points})"
101 if $opts{points} and $opts{points} !~ /^\d+$/;
103 my @storage = $clearadm->GetStoragePool(
114 graphError "No data found for $opts{type} $opts{tag} for storage pool $opts{storage}"
128 push @x, $storage{timestamp};
131 push @y, $opts{meg} ? $storage{size} / (1024 * 1024) :
132 $storage{size} / (1024 * 1024 * 12024);
135 my @data = ([@x], [@y]);
137 my $x_label_skip = @x > 1000 ? 200
143 my $storageLabel = ucfirst $opts{storage};
144 my $x_label = $opts{tiny} ? '' : "$storageLabel Storage";
145 my $y_label = $opts{tiny} ? '' :
146 $opts{msg} ? 'Used (Meg)' : 'Used (Gig)';
147 my $title = $opts{tiny} ? '' : "Storage usage for "
148 . "$opts{type}:$opts{tag} $storageLabel";
149 my $labelY = $opts{tiny} ? '' : '%.2f';
153 x_labels_vertical => 1,
154 x_label_skip => $x_label_skip,
155 x_label_position => .5,
157 y_number_format => $labelY,
159 dclrs => [$opts{color}],
167 ) or graphError $graph->error;
169 my $image = $graph->plot(\@data)
170 or croak $graph->error;
172 unless ($opts{generate}) {
173 print "Content-type: image/png\n\n";
176 print encode_base64 $image->png;
181 =head1 CONFIGURATION AND ENVIRONMENT
183 DEBUG: If set then $debug is set to this level.
185 VERBOSE: If set then $verbose is set to this level.
187 TRACE: If set then $trace is set to this level.
197 L<Getopt::Long|Getopt::Long>
199 L<GD::Graph::area|GD::Graph::area>
201 =head2 ClearSCM Perl Modules
214 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearadm.pm">Clearadm</a><br>
215 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/ClearadmWeb.pm">ClearadmWeb</a><br>
216 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
221 =head1 BUGS AND LIMITATIONS
223 There are no known bugs in this script
225 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
227 =head1 LICENSE AND COPYRIGHT
229 Copyright (c) 2010, ClearSCM, Inc. All rights reserved.