projects
/
clearscm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed announceEmail.pl to be less busy
[clearscm.git]
/
clearadm
/
plotfs.cgi
diff --git
a/clearadm/plotfs.cgi
b/clearadm/plotfs.cgi
index
180dd26
..
e02bd10
100755
(executable)
--- a/
clearadm/plotfs.cgi
+++ b/
clearadm/plotfs.cgi
@@
-1,4
+1,4
@@
-#!/usr/bin/perl
+#!/usr/
local/
bin/perl
=pod
=pod
@@
-61,6
+61,7
@@
use strict;
use warnings;
use FindBin;
use warnings;
use FindBin;
+use Convert::Base64;
use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib";
use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib";
@@
-68,7
+69,7
@@
use Clearadm;
use ClearadmWeb;
use Display;
use ClearadmWeb;
use Display;
-use CGI qw
(:standard :cgi-lib);
+use CGI qw(:standard :cgi-lib);
use GD::Graph::area;
my %opts = Vars;
use GD::Graph::area;
my %opts = Vars;
@@
-87,15
+88,9
@@
if ($opts{tiny}) {
$opts{scaling} = 'Day';
} # if
$opts{scaling} = 'Day';
} # if
-sub labelY ($) {
- my ($value) = @_;
-
- return $opts{tiny} ? '' : $value;
-} # labelY
-
my $clearadm = Clearadm->new;
my $clearadm = Clearadm->new;
-my $graph = GD::Graph::area->new
($opts{width}, $opts{height});
+my $graph = GD::Graph::area->new($opts{width}, $opts{height});
graphError "System is required"
unless $opts{system};
graphError "System is required"
unless $opts{system};
@@
-106,7
+101,7
@@
graphError "Filesystem is required"
graphError "Points not numeric (points: $opts{points})"
if $opts{points} and $opts{points} !~ /^\d+$/;
graphError "Points not numeric (points: $opts{points})"
if $opts{points} and $opts{points} !~ /^\d+$/;
-my @fs = $clearadm->GetFS
(
+my @fs = $clearadm->GetFS(
$opts{system},
$opts{filesystem},
$opts{start},
$opts{system},
$opts{filesystem},
$opts{start},
@@
-122,7
+117,7
@@
my (@x, @y);
my $i = 0;
my $i = 0;
-for
each
(@fs) {
+for (@fs) {
$i++;
my %fs = %{$_};
$i++;
my %fs = %{$_};
@@
-132,8
+127,10
@@
foreach (@fs) {
push @x, $fs{timestamp};
} # if
push @x, $fs{timestamp};
} # if
- push @y, sprintf ('%.2f', $fs{used} / (1024 * 1024));
-}
+ push @y, $opts{meg} ? $fs{used} / (1024 * 1024) :
+ $fs{used} / (1024 * 1024 * 12024);
+} # for
+
my @data = ([@x], [@y]);
my $x_label_skip = @x > 1000 ? 200
my @data = ([@x], [@y]);
my $x_label_skip = @x > 1000 ? 200
@@
-143,17
+140,19
@@
my $x_label_skip = @x > 1000 ? 200
: 0;
my $x_label = $opts{tiny} ? '' : 'Filesystem Usage';
: 0;
my $x_label = $opts{tiny} ? '' : 'Filesystem Usage';
-my $y_label = $opts{tiny} ? '' : 'Used (Meg)';
+my $y_label = $opts{tiny} ? '' :
+ $opts{msg} ? 'Used (Meg)' : 'Used (Gig)';
my $title = $opts{tiny} ? '' : "Filesystem usage for "
. "$opts{system}:$opts{filesystem}";
my $title = $opts{tiny} ? '' : "Filesystem usage for "
. "$opts{system}:$opts{filesystem}";
+my $labelY = $opts{tiny} ? '' : '%.2f';
-$graph->set
(
+$graph->set(
x_label =>$x_label,
x_labels_vertical => 1,
x_label_skip => $x_label_skip,
x_label_position => .5,
y_label => $y_label,
x_label =>$x_label,
x_labels_vertical => 1,
x_label_skip => $x_label_skip,
x_label_position => .5,
y_label => $y_label,
- y_number_format =>
&
labelY,
+ y_number_format =>
$
labelY,
title => $title,
dclrs => [$opts{color}],
bgclr => 'white',
title => $title,
dclrs => [$opts{color}],
bgclr => 'white',
@@
-168,8
+167,12
@@
$graph->set (
my $image = $graph->plot(\@data)
or croak $graph->error;
my $image = $graph->plot(\@data)
or croak $graph->error;
-print "Content-type: image/png\n\n";
-print $image->png;
+unless ($opts{generate}) {
+ print "Content-type: image/png\n\n";
+ print $image->png;
+} else {
+ print encode_base64 $image->png;
+} # unless
=pod
=pod