X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=clearadm%2Fplotfs.cgi;h=e02bd10530617624bc5712eb20642974e82b0a08;hb=7ddf095f187ca60d9a70fb83b2bc3c2b6d91f088;hp=8617e79337ef6af1deecf454bbdcdad359762b8e;hpb=0c802537ec02d6cfea4c41b3138535c09a319489;p=clearscm.git diff --git a/clearadm/plotfs.cgi b/clearadm/plotfs.cgi index 8617e79..e02bd10 100755 --- a/clearadm/plotfs.cgi +++ b/clearadm/plotfs.cgi @@ -61,6 +61,7 @@ use strict; use warnings; use FindBin; +use Convert::Base64; use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib"; @@ -68,7 +69,7 @@ use Clearadm; use ClearadmWeb; use Display; -use CGI qw (:standard :cgi-lib); +use CGI qw(:standard :cgi-lib); use GD::Graph::area; my %opts = Vars; @@ -89,7 +90,7 @@ if ($opts{tiny}) { 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}; @@ -100,7 +101,7 @@ graphError "Filesystem is required" 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}, @@ -116,7 +117,7 @@ my (@x, @y); my $i = 0; -foreach (@fs) { +for (@fs) { $i++; my %fs = %{$_}; @@ -128,7 +129,8 @@ foreach (@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 @@ -144,7 +146,7 @@ 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, @@ -165,8 +167,12 @@ $graph->set ( 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