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: (.*) /);
62 $parms .= '&' if $parms;
63 $parms .= "$_=$opts{$_}"
68 if ($opts{type} eq 'loadavg') {
69 unless ($opts{tiny}) {
70 display img {src => "plotloadavg.cgi?$parms", class => 'chart'};
72 display img {src => "plotloadavg.cgi?$parms", border => 0};
74 } elsif ($opts{type} eq 'filesystem') {
75 unless ($opts{tiny}) {
76 display img {src => "plotfs.cgi?$parms", class => 'chart'};
78 display img {src => "plotfs.cgi?$parms", border => 0};
80 } elsif ($opts{type} eq 'vob' or $opts{type} eq 'view') {
81 unless ($opts{tiny}) {
82 display img {src => "plotstorage.cgi?$parms", class => 'chart'};
84 display img {src => "plotstorage.cgi?$parms", border => 0};
93 sub displayFSInfo () {
94 if ($opts{filesystem}) {
95 display h3 {-align => 'center'}, 'Latest Filesystem Reading';
101 display start_table {width => '800px', cellspacing => 1};
104 display th {class => 'labelCentered'}, 'Filesystem';
105 display th {class => 'labelCentered'}, 'Type';
106 display th {class => 'labelCentered'}, 'Mount';
107 display th {class => 'labelCentered'}, 'Size';
108 display th {class => 'labelCentered'}, 'Used';
109 display th {class => 'labelCentered'}, 'Free';
110 display th {class => 'labelCentered'}, 'Used %';
111 display th {class => 'labelCentered'}, 'History';
112 display th {class => 'labelCentered'}, 'Threshold';
115 my %filesystem = $clearadm->GetFilesystem (
119 my %fs = $clearadm->GetLatestFS (
124 my $size = autoScale $fs{size};
125 my $used = autoScale $fs{used};
126 my $free = autoScale $fs{free};
129 display td {class => 'data'}, $filesystem{filesystem};
130 display td {class => 'dataCentered'}, $filesystem{fstype};
131 display td {class => 'data'}, $filesystem{mount};
132 display td {class => 'dataRight'}, $size;
133 display td {class => 'dataRight'}, $used;
134 display td {class => 'dataRight'}, $free;
135 # TODO: Note that this percentages does not agree with df output. I'm not
137 display td {class => 'dataCentered'},
138 sprintf ('%.0f%%', (($fs{reserve} + $fs{used}) / $fs{size} * 100));
139 display td {class => 'dataCentered'}, $filesystem{filesystemHist};
140 display td {class => 'dataCentered'}, "$filesystem{threshold}%";
148 sub displayControls() {
149 my $class = $opts{type} =~ /loadavg/i
151 : 'filesystemControls';
153 display start_table {
161 my ($systemLink, $systemButtons);
163 if ($opts{type} =~ /(vob|view)/i) {
164 $tagsButtons = makeTagsDropdown ($opts{type}, $opts{tag});
166 $systemLink = span {id => 'systemLink'}, a {
167 href => "systemdetails.cgi?system=$opts{system}",
170 $systemButtons = makeSystemDropdown (
173 'updateFilesystems(this.value);updateSystemLink(this.value)'
177 my $startButtons = makeTimeDropdown (
187 my $endButtons = makeTimeDropdown (
199 if ($opts{type} eq 'loadavg') {
200 $update = "updateSystem('$opts{system}')";
201 } elsif ($opts{type} eq 'filsystem') {
202 $update = "updateFilesystem('$opts{system}','$opts{filesystem}')";
204 $update = ''; # TODO do I need something here?
207 my $intervalButtons = makeIntervalDropdown (
214 display td $startButtons;
215 display td $intervalButtons;
216 display td $opts{type} =~ /(vob|view)/i ? $tagsButtons : $systemButtons;
220 display td $endButtons;
224 value => $opts{points},
225 class => 'inputfield',
227 style => 'text-align: right',
231 if ($opts{type} eq 'loadavg') {
234 value => 'Draw Graph',
237 if ($opts{type} eq 'filesystem') {
238 my $filesystemButtons = makeFilesystemDropdown (
242 "updateFilesystem('$opts{system}',this.value)",
245 display td $filesystemButtons;
247 my $storagePoolButtons = makeStoragePoolDropdown ($opts{type}, $opts{tag});
249 display td $storagePoolButtons;
254 display td {align => 'center', colspan => 3},
255 input {type => 'submit', value => 'Draw Graph'};
265 $clearadm = Clearadm->new;
267 my $title = ucfirst ($opts{type}) . ': ';
269 $title .= ucfirst $opts{system} if $opts{system};
270 $title .= ":$opts{filesystem}" if $opts{filesystem};
271 $title .= $opts{tag} if $opts{tag};
272 $title .= " Storage pool: $opts{storage}" if $opts{storage};
276 display h1 {class => 'center'}, $title;
280 action => 'plot.cgi',
283 # Some hidden fields to pass along
284 display input {type => 'hidden', name => 'type', value => $opts{type}};
296 =head1 CONFIGURATION AND ENVIRONMENT
298 DEBUG: If set then $debug is set to this level.
300 VERBOSE: If set then $verbose is set to this level.
302 TRACE: If set then $trace is set to this level.
310 L<CGI::Carp|CGI::Carp>
314 L<Getopt::Long|Getopt::Long>
316 =head2 ClearSCM Perl Modules
329 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearadm.pm">Clearadm</a><br>
330 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/ClearadmWeb.pm">ClearadmWeb</a><br>
331 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
336 =head1 BUGS AND LIMITATIONS
338 There are no known bugs in this script
340 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
342 =head1 LICENSE AND COPYRIGHT
344 Copyright (c) 2010, ClearSCM, Inc. All rights reserved.