use warnings;
use FindBin;
+use Convert::Base64;
use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib";
use ClearadmWeb;
use Display;
-use CGI qw (:standard :cgi-lib);
+use CGI qw(:standard :cgi-lib);
use GD::Graph::area;
my %opts = Vars;
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 "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},
my $i = 0;
-foreach (@fs) {
+for (@fs) {
$i++;
my %fs = %{$_};
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
. "$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,
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