-#!/usr/bin/perl
+#!/usr/local/bin/perl
=pod
use warnings;
use FindBin;
-use CGI qw (:standard :cgi-lib start_table end_table start_Tr end_Tr);
+use CGI qw(:standard :cgi-lib start_table end_table start_Tr end_Tr);
use GD::Graph::area;
use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib";
my $clearadm;
-sub displayGraph () {
+sub displayGraph() {
my $parms;
- foreach (keys %opts) {
- $parms .= '&'
- if $parms;
+ for (keys %opts) {
+ $parms .= '&' if $parms;
$parms .= "$_=$opts{$_}"
- } # foreach
+ } # for
display '<center>';
if ($opts{type} eq 'loadavg') {
- unless ($opts{tiny}) {
- display img {src => "plotloadavg.cgi?$parms", class => 'chart'};
- } else {
- display img {src => "plotloadavg.cgi?$parms", border => 0};
- } # unless
+ my %system = $clearadm->GetSystem($opts{system});
+
+ # We can use the cached version only if the opts are set to default
+ if ($opts{scaling} eq 'Hour' and $opts{points} == 24) {
+ my $data = $opts{tiny} ? $system{loadavgsmall} : $system{loadavg};
+
+ display img {src => "data:image/png;base64,$data"};
+ } else {
+ unless ($opts{tiny}) {
+ display img {src => "plotloadavg.cgi?$parms", class => 'chart'};
+ } else {
+ display img {src => "plotloadavg.cgi?$parms", border => 0};
+ } # unless
+ } # if
} elsif ($opts{type} eq 'filesystem') {
- unless ($opts{tiny}) {
- display img {src => "plotfs.cgi?$parms", class => 'chart'};
- } else {
- display img {src => "plotfs.cgi?$parms", border => 0};
- } # unless
+ my %filesystem = $clearadm->GetFilesystem($opts{system}, $opts{filesystem});
+
+ # We can use the cached version only if the opts are set to default
+ if ($opts{scaling} eq 'Day' and $opts{points} == 7) {
+ my $data = $opts{tiny} ? $filesystem{fssmall} : $filesystem{fslarge};
+
+ display img {src => "data:image/png;base64,$data"};
+ } else {
+ unless ($opts{tiny}) {
+ display img {src => "plotfs.cgi?$parms", class => 'chart'};
+ } else {
+ display img {src => "plotfs.cgi?$parms", border => 0};
+ } # unless
+ } # if
+ } elsif ($opts{type} eq 'vob' or $opts{type} eq 'view') {
+ my (%vob, %view);
+
+ %vob = $clearadm->GetVob($opts{tag}, $opts{region}) if $opts{type} eq 'vob';
+ %view = $clearadm->GetView($opts{tag}, $opts{region}) if $opts{type} eq 'view';
+ # We can use the cached version only if the opts are set to default
+ if ($opts{scaling} eq 'Day' and $opts{points} == 7) {
+ my $storageType = $opts{tiny} ? "$opts{storage}small" : "$opts{storage}large";
+ my $data = $opts{type} eq 'vob' ? $vob{$storageType} : $view{$storageType};
+
+ display img {src => "data:image/png;base64,$data"};
+ } else {
+ unless ($opts{tiny}) {
+ display img {src => "plotstorage.cgi?$parms", class => 'chart'};
+ } else {
+ display img {src => "plotstorage.cgi?$parms", border => 0};
+ } # unless
+ } # if
} # if
display '</center>';
- return
+ return;
} # displayGraph
-sub displayFSInfo () {
+sub displayFSInfo() {
if ($opts{filesystem}) {
display h3 {-align => 'center'}, 'Latest Filesystem Reading';
} else {
- display p;
- return;
+ display p;
+ return;
} # if
display start_table {width => '800px', cellspacing => 1};
return;
} # displayInfo
-sub displayControls () {
+sub displayControls() {
my $class = $opts{type} =~ /loadavg/i
? 'controls'
: 'filesystemControls';
width => '800px',
};
- my $systemLink = span {id => 'systemLink'}, a {
- href => "systemdetails.cgi?system=$opts{system}",
- }, 'System';
+ my $tagsButtons;
+ my ($systemLink, $systemButtons);
- my $systemButtons = makeSystemDropdown (
- $systemLink,
- $opts{system},
- 'updateFilesystems(this.value);updateSystemLink(this.value)'
- );
+ if ($opts{type} =~ /(vob|view)/i) {
+ $tagsButtons = makeTagsDropdown($opts{type}, $opts{tag});
+ } else {
+ $systemLink = span {id => 'systemLink'}, a {
+ href => "systemdetails.cgi?system=$opts{system}",
+ }, 'System';
+
+ $systemButtons = makeSystemDropdown(
+ $systemLink,
+ $opts{system},
+ 'updateFilesystems(this.value);updateSystemLink(this.value)'
+ );
+ } # if
- my $startButtons = makeTimeDropdown (
+ my $startButtons = makeTimeDropdown(
$opts{type},
'startTimestamp',
$opts{system},
$opts{scaling},
);
- my $endButtons = makeTimeDropdown (
+ my $endButtons = makeTimeDropdown(
$opts{type},
'endTimestamp',
$opts{system},
$opts{scaling},
);
- my $update = $opts{type} eq 'loadavg'
- ? "updateSystem('$opts{system}')"
- : "updateFilesystem('$opts{system}','$opts{filesystem}')";
+ my $update;
+
+ if ($opts{type} eq 'loadavg') {
+ $update = "updateSystem('$opts{system}')";
+ } elsif ($opts{type} eq 'filsystem') {
+ $update = "updateFilesystem('$opts{system}','$opts{filesystem}')";
+ } else {
+ $update = ''; # TODO do I need something here?
+ } # if
- my $intervalButtons = makeIntervalDropdown (
+ my $intervalButtons = makeIntervalDropdown(
'Interval',
$opts{scaling},
$update
display start_Tr;
display td $startButtons;
display td $intervalButtons;
- display td $systemButtons;
+ display td $opts{type} =~ /(vob|view)/i ? $tagsButtons : $systemButtons;
display end_Tr;
display start_Tr;
value => 'Draw Graph',
};
} else {
- my $filesystemButtons = makeFilesystemDropdown (
- $opts{system},
- 'Filesystem',
- undef,
- "updateFilesystem('$opts{system}',this.value)",
- );
+ if ($opts{type} eq 'filesystem') {
+ my $filesystemButtons = makeFilesystemDropdown (
+ $opts{system},
+ 'Filesystem',
+ undef,
+ "updateFilesystem('$opts{system}',this.value)",
+ );
- display td $filesystemButtons;
+ display td $filesystemButtons;
+ } else {
+ my $storagePoolButtons = makeStoragePoolDropdown ($opts{type}, $opts{tag});
+
+ display td $storagePoolButtons;
+ } # if
display end_Tr;
display start_Tr;
$clearadm = Clearadm->new;
-my $title = ucfirst ($opts{type}) . ': ' . ucfirst $opts{system};
+my $title = ucfirst($opts{type}) . ': ';
-$title .= ":$opts{filesystem}"
- if $opts{filesystem};
+$title .= ucfirst $opts{system} if $opts{system};
+$title .= ":$opts{filesystem}" if $opts{filesystem};
+$title .= $opts{tag} if $opts{tag};
+$title .= " Storage pool: $opts{storage}" if $opts{storage};
heading $title;
};
# Some hidden fields to pass along
-display input {type => 'hidden', name => 'type', value => $opts{type}};
+display input {type => 'hidden', name => 'type', value => $opts{type}};
+display input {type => 'hidden', name => 'region', value => $opts{region}};
displayGraph;
displayFSInfo;
=begin html
<blockquote>
-<a href="http://clearscm.com/php/cvs_man.php?file=clearadm/lib/Clearadm.pm">Clearadm</a><br>
-<a href="http://clearscm.com/php/cvs_man.php?file=clearadm/lib/ClearadmWeb.pm">ClearadmWeb</a><br>
-<a href="http://clearscm.com/php/cvs_man.php?file=lib/Display.pm">Display</a><br>
+<a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearadm.pm">Clearadm</a><br>
+<a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/ClearadmWeb.pm">ClearadmWeb</a><br>
+<a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
</blockquote>
=end html
Copyright (c) 2010, ClearSCM, Inc. All rights reserved.
-=cut
\ No newline at end of file
+=cut