5 =head1 NAME $RCSfile: plot.cgi,v $
15 Andrew DeFaria <Andrew@ClearSCM.com>
23 Mon Oct 25 11:10:47 PDT 2008
27 $Date: 2011/01/28 21:30:45 $
33 Display a graph of either Loadavg or Filesystem data and provide controls for
34 the user to manipulate the chart.
42 use CGI qw (:standard :cgi-lib start_table end_table start_Tr end_Tr);
45 use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib";
51 my $VERSION = '$Revision: 1.14 $';
52 ($VERSION) = ($VERSION =~ /\$Revision: (.*) /);
61 foreach (keys %opts) {
64 $parms .= "$_=$opts{$_}"
69 if ($opts{type} eq 'loadavg') {
70 unless ($opts{tiny}) {
71 display img {src => "plotloadavg.cgi?$parms", class => 'chart'};
73 display img {src => "plotloadavg.cgi?$parms", border => 0};
75 } elsif ($opts{type} eq 'filesystem') {
76 unless ($opts{tiny}) {
77 display img {src => "plotfs.cgi?$parms", class => 'chart'};
79 display img {src => "plotfs.cgi?$parms", border => 0};
88 sub displayFSInfo () {
89 if ($opts{filesystem}) {
90 display h3 {-align => 'center'}, 'Latest Filesystem Reading';
96 display start_table {width => '800px', cellspacing => 1};
99 display th {class => 'labelCentered'}, 'Filesystem';
100 display th {class => 'labelCentered'}, 'Type';
101 display th {class => 'labelCentered'}, 'Mount';
102 display th {class => 'labelCentered'}, 'Size';
103 display th {class => 'labelCentered'}, 'Used';
104 display th {class => 'labelCentered'}, 'Free';
105 display th {class => 'labelCentered'}, 'Used %';
106 display th {class => 'labelCentered'}, 'History';
107 display th {class => 'labelCentered'}, 'Threshold';
110 my %filesystem = $clearadm->GetFilesystem (
114 my %fs = $clearadm->GetLatestFS (
119 my $size = autoScale $fs{size};
120 my $used = autoScale $fs{used};
121 my $free = autoScale $fs{free};
124 display td {class => 'data'}, $filesystem{filesystem};
125 display td {class => 'dataCentered'}, $filesystem{fstype};
126 display td {class => 'data'}, $filesystem{mount};
127 display td {class => 'dataRight'}, $size;
128 display td {class => 'dataRight'}, $used;
129 display td {class => 'dataRight'}, $free;
130 # TODO: Note that this percentages does not agree with df output. I'm not
132 display td {class => 'dataCentered'},
133 sprintf ('%.0f%%', (($fs{reserve} + $fs{used}) / $fs{size} * 100));
134 display td {class => 'dataCentered'}, $filesystem{filesystemHist};
135 display td {class => 'dataCentered'}, "$filesystem{threshold}%";
143 sub displayControls () {
144 my $class = $opts{type} =~ /loadavg/i
146 : 'filesystemControls';
148 display start_table {
155 my $systemLink = span {id => 'systemLink'}, a {
156 href => "systemdetails.cgi?system=$opts{system}",
159 my $systemButtons = makeSystemDropdown (
162 'updateFilesystems(this.value);updateSystemLink(this.value)'
165 my $startButtons = makeTimeDropdown (
175 my $endButtons = makeTimeDropdown (
185 my $update = $opts{type} eq 'loadavg'
186 ? "updateSystem('$opts{system}')"
187 : "updateFilesystem('$opts{system}','$opts{filesystem}')";
189 my $intervalButtons = makeIntervalDropdown (
196 display td $startButtons;
197 display td $intervalButtons;
198 display td $systemButtons;
202 display td $endButtons;
206 value => $opts{points},
207 class => 'inputfield',
209 style => 'text-align: right',
213 if ($opts{type} eq 'loadavg') {
216 value => 'Draw Graph',
219 my $filesystemButtons = makeFilesystemDropdown (
223 "updateFilesystem('$opts{system}',this.value)",
226 display td $filesystemButtons;
230 display td {align => 'center', colspan => 3},
231 input {type => 'submit', value => 'Draw Graph'};
241 $clearadm = Clearadm->new;
243 my $title = ucfirst ($opts{type}) . ': ' . ucfirst $opts{system};
245 $title .= ":$opts{filesystem}"
246 if $opts{filesystem};
250 display h1 {class => 'center'}, $title;
254 action => 'plot.cgi',
257 # Some hidden fields to pass along
258 display input {type => 'hidden', name => 'type', value => $opts{type}};
270 =head1 CONFIGURATION AND ENVIRONMENT
272 DEBUG: If set then $debug is set to this level.
274 VERBOSE: If set then $verbose is set to this level.
276 TRACE: If set then $trace is set to this level.
284 L<CGI::Carp|CGI::Carp>
288 L<Getopt::Long|Getopt::Long>
290 =head2 ClearSCM Perl Modules
303 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearadm.pm">Clearadm</a><br>
304 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/ClearadmWeb.pm">ClearadmWeb</a><br>
305 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
310 =head1 BUGS AND LIMITATIONS
312 There are no known bugs in this script
314 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
316 =head1 LICENSE AND COPYRIGHT
318 Copyright (c) 2010, ClearSCM, Inc. All rights reserved.