5 =head1 NAME $RCSfile: plotfs.cgi,v $
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 plotfs.cgi: system=<system> filesytem=<filesystem>
34 [height=<height>] [width=<width>] [color=<color>]
35 [scaling=<scaling>] [points=<points>] [tiny=<0|1>]
38 <system>: Name of the system defined in the Clearadm database to
39 retrieve filesystem snapshots for.
40 <filesystem>: Name of the filesytem 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: lblue)
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 filesystem usage for the system and filesystem passed in.
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 systemdetails.cgi to
55 draw tiny charts in the table. Setting tiny sets a number of the other chart
56 options to produce a standard, tiny chart.
65 use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib";
71 use CGI qw (:standard :cgi-lib);
76 my $VERSION = '$Revision: 1.13 $';
77 ($VERSION) = ($VERSION =~ /\$Revision: (.*) /);
79 $opts{color} ||= 'lblue';
80 $opts{height} ||= 350;
87 $opts{scaling} = 'Day';
90 my $clearadm = Clearadm->new;
92 my $graph = GD::Graph::area->new ($opts{width}, $opts{height});
94 graphError "System is required"
97 graphError "Filesystem is required"
98 unless $opts{filesystem};
100 graphError "Points not numeric (points: $opts{points})"
101 if $opts{points} and $opts{points} !~ /^\d+$/;
103 my @fs = $clearadm->GetFS (
112 graphError "No data found for $opts{system}:$opts{filesystem}"
126 push @x, $fs{timestamp};
129 push @y, $opts{meg} ? $fs{used} / (1024 * 1024) :
130 $fs{used} / (1024 * 1024 * 12024);
132 my @data = ([@x], [@y]);
134 my $x_label_skip = @x > 1000 ? 200
140 my $x_label = $opts{tiny} ? '' : 'Filesystem Usage';
141 my $y_label = $opts{tiny} ? '' :
142 $opts{msg} ? 'Used (Meg)' : 'Used (Gig)';
143 my $title = $opts{tiny} ? '' : "Filesystem usage for "
144 . "$opts{system}:$opts{filesystem}";
145 my $labelY = $opts{tiny} ? '' : '%.2f';
149 x_labels_vertical => 1,
150 x_label_skip => $x_label_skip,
151 x_label_position => .5,
153 y_number_format => $labelY,
155 dclrs => [$opts{color}],
163 ) or graphError $graph->error;
165 my $image = $graph->plot(\@data)
166 or croak $graph->error;
168 print "Content-type: image/png\n\n";
173 =head1 CONFIGURATION AND ENVIRONMENT
175 DEBUG: If set then $debug is set to this level.
177 VERBOSE: If set then $verbose is set to this level.
179 TRACE: If set then $trace is set to this level.
189 L<Getopt::Long|Getopt::Long>
191 L<GD::Graph::area|GD::Graph::area>
193 =head2 ClearSCM Perl Modules
206 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearadm.pm">Clearadm</a><br>
207 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/ClearadmWeb.pm">ClearadmWeb</a><br>
208 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
213 =head1 BUGS AND LIMITATIONS
215 There are no known bugs in this script
217 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
219 =head1 LICENSE AND COPYRIGHT
221 Copyright (c) 2010, ClearSCM, Inc. All rights reserved.