projects
/
clearscm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Changed to not try new images while the monitor is off
[clearscm.git]
/
clearadm
/
plotloadavg.cgi
diff --git
a/clearadm/plotloadavg.cgi
b/clearadm/plotloadavg.cgi
index
853edd8
..
d5cb7ca
100755
(executable)
--- a/
clearadm/plotloadavg.cgi
+++ b/
clearadm/plotloadavg.cgi
@@
-1,4
+1,4
@@
-#!/usr/bin/perl
+#!/usr/
local/
bin/perl
=pod
=pod
@@
-59,6
+59,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";
@@
-66,7
+67,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,7
+88,7
@@
if ($opts{tiny}) {
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};
@@
-95,20
+96,20
@@
graphError "System 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 @loads = $clearadm->GetLoadavg
(
+my @loads = $clearadm->GetLoadavg(
$opts{system},
$opts{start},
$opts{end},
$opts{points},
$opts{system},
$opts{start},
$opts{end},
$opts{points},
- $opts{scaling}
+ $opts{scaling}
,
);
);
-graphError "No loadavg data
found for system $opts{system}
"
+graphError "No loadavg data"
unless @loads;
my (@x, @y);
unless @loads;
my (@x, @y);
-for
each
(@loads) {
+for (@loads) {
my %load = %{$_};
if ($opts{tiny}) {
my %load = %{$_};
if ($opts{tiny}) {
@@
-118,7
+119,7
@@
foreach (@loads) {
} # if
push @y, $load{loadavg};
} # if
push @y, $load{loadavg};
-} # for
each
+} # for
my @data = ([@x], [@y]);
my @data = ([@x], [@y]);
@@
-133,7
+134,7
@@
my $y_label = $opts{tiny} ? '' : 'Load';
my $title = $opts{tiny} ? '' : "Load Average for $opts{system}";
my $labelY = $opts{tiny} ? '' : '%.2f';
my $title = $opts{tiny} ? '' : "Load Average for $opts{system}";
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 => $x_label,
x_labels_vertical => 1,
x_label_skip => $x_label_skip,
@@
-154,8
+155,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
@@
-207,4
+212,4
@@
Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
Copyright (c) 2010, ClearSCM, Inc. All rights reserved.
Copyright (c) 2010, ClearSCM, Inc. All rights reserved.
-=cut
\ No newline at end of file
+=cut