5 =head1 NAME $RCSfile: plotloadavg.cgi,v $
7 Plot loadavg for a system
15 Andrew DeFaria <Andrew@ClearSCM.com>
23 Mon Dec 13 09:13:27 EST 2010
27 $Date: 2011/01/20 14:34:24 $
33 Usage plotfs.cgi: system=<system>
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 loadavgs snapshots for.
40 <height>: Height of chart (Default: 480px - tiny: 40)
41 <width>: Width of chart (Default: 800px - tiny: 150)
42 <color>: A GD::Color color value (Default: lblue)
43 <scaling>: Currently one of Minute, Hour, Day or Month. Specifies how
44 Clearadm::GetFS will scale the data returned (Default: Minute
46 <points>: Number of points to plot (Default: all points - tiny: 7)
50 Draws a chart of loadavg for the system passed in. Parameters such as height,
51 width, color, scaling and points can be set individually though more often the
52 user will just use the web controls to set them. Defaults produce a nice chart.
53 Tiny mode is used by systemdetails.cgi to draw tiny charts in the table. Setting
54 tiny sets a number of the other chart options to produce a standard, tiny chart.
63 use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib";
69 use CGI qw (:standard :cgi-lib);
74 my $VERSION = '$Revision: 1.15 $';
75 ($VERSION) = ($VERSION =~ /\$Revision: (.*) /);
77 $opts{color} ||= 'lyellow';
78 $opts{height} ||= 400;
85 $opts{scaling} = 'Hour';
88 my $clearadm = Clearadm->new;
90 my $graph = GD::Graph::area->new ($opts{width}, $opts{height});
92 graphError "System is required"
95 graphError "Points not numeric (points: $opts{points})"
96 if $opts{points} and $opts{points} !~ /^\d+$/;
98 my @loads = $clearadm->GetLoadavg (
106 graphError "No loadavg data"
117 push @x, $load{timestamp};
120 push @y, $load{loadavg};
123 my @data = ([@x], [@y]);
125 my $x_label_skip = @x > 1000 ? 200
131 my $x_label = $opts{tiny} ? '' : 'Time';
132 my $y_label = $opts{tiny} ? '' : 'Load';
133 my $title = $opts{tiny} ? '' : "Load Average for $opts{system}";
134 my $labelY = $opts{tiny} ? '' : '%.2f';
138 x_labels_vertical => 1,
139 x_label_skip => $x_label_skip,
140 x_label_position => .5,
142 y_number_format => $labelY,
144 dclrs => [$opts{color}],
152 ) or graphError $graph->error;
154 my $image = $graph->plot(\@data)
155 or croak $graph->error;
157 print "Content-type: image/png\n\n";
162 =head1 CONFIGURATION AND ENVIRONMENT
164 DEBUG: If set then $debug is set to this level.
166 VERBOSE: If set then $verbose is set to this level.
168 TRACE: If set then $trace is set to this level.
178 L<GD::Graph::area|GD::Graph::area>
180 =head2 ClearSCM Perl Modules
193 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearadm.pm">Clearadm</a><br>
194 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/ClearadmWeb.pm">ClearadmWeb</a><br>
195 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
200 =head1 BUGS AND LIMITATIONS
202 There are no known bugs in this script
204 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
206 =head1 LICENSE AND COPYRIGHT
208 Copyright (c) 2010, ClearSCM, Inc. All rights reserved.