mirror of https://github.com/mikaku/Monitorix.git
redirect all the output into an array to support parallelizing in 'ipmi.pm'
This commit is contained in:
parent
3f6f9d4034
commit
bcc6cc2b13
67
lib/ipmi.pm
67
lib/ipmi.pm
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
# Monitorix - A lightweight system monitoring tool.
|
# Monitorix - A lightweight system monitoring tool.
|
||||||
#
|
#
|
||||||
# Copyright (C) 2005-2016 by Jordi Sanfeliu <jordi@fibranet.cat>
|
# Copyright (C) 2005-2017 by Jordi Sanfeliu <jordi@fibranet.cat>
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -211,6 +211,7 @@ sub ipmi_update {
|
||||||
|
|
||||||
sub ipmi_cgi {
|
sub ipmi_cgi {
|
||||||
my ($package, $config, $cgi) = @_;
|
my ($package, $config, $cgi) = @_;
|
||||||
|
my @output;
|
||||||
|
|
||||||
my $ipmi = $config->{ipmi};
|
my $ipmi = $config->{ipmi};
|
||||||
my @rigid = split(',', ($ipmi->{rigid} || ""));
|
my @rigid = split(',', ($ipmi->{rigid} || ""));
|
||||||
|
@ -269,21 +270,21 @@ sub ipmi_cgi {
|
||||||
#
|
#
|
||||||
if(lc($config->{iface_mode}) eq "text") {
|
if(lc($config->{iface_mode}) eq "text") {
|
||||||
if($title) {
|
if($title) {
|
||||||
main::graph_header($title, 2);
|
push(@output, main::graph_header($title, 2));
|
||||||
print(" <tr>\n");
|
push(@output, " <tr>\n");
|
||||||
print(" <td bgcolor='$colors->{title_bg_color}'>\n");
|
push(@output, " <td bgcolor='$colors->{title_bg_color}'>\n");
|
||||||
}
|
}
|
||||||
my (undef, undef, undef, $data) = RRDs::fetch("$rrd",
|
my (undef, undef, undef, $data) = RRDs::fetch("$rrd",
|
||||||
"--start=-$tf->{nwhen}$tf->{twhen}",
|
"--start=-$tf->{nwhen}$tf->{twhen}",
|
||||||
"AVERAGE",
|
"AVERAGE",
|
||||||
"-r $tf->{res}");
|
"-r $tf->{res}");
|
||||||
$err = RRDs::error;
|
$err = RRDs::error;
|
||||||
print("ERROR: while fetching $rrd: $err\n") if $err;
|
push(@output, "ERROR: while fetching $rrd: $err\n") if $err;
|
||||||
my $line1;
|
my $line1;
|
||||||
my $line2;
|
my $line2;
|
||||||
my $line3;
|
my $line3;
|
||||||
print(" <pre style='font-size: 12px; color: $colors->{fg_color}';>\n");
|
push(@output, " <pre style='font-size: 12px; color: $colors->{fg_color}';>\n");
|
||||||
print(" ");
|
push(@output, " ");
|
||||||
for($n = 0; $n < scalar(my @sl = split(',', $ipmi->{list})); $n++) {
|
for($n = 0; $n < scalar(my @sl = split(',', $ipmi->{list})); $n++) {
|
||||||
$line1 = "";
|
$line1 = "";
|
||||||
foreach my $i (split(',', $ipmi->{desc}->{$n})) {
|
foreach my $i (split(',', $ipmi->{desc}->{$n})) {
|
||||||
|
@ -296,12 +297,12 @@ sub ipmi_cgi {
|
||||||
}
|
}
|
||||||
if($line1) {
|
if($line1) {
|
||||||
my $i = length($line1);
|
my $i = length($line1);
|
||||||
printf(sprintf("%${i}s", sprintf("%s", trim($sl[$n]))));
|
push(@output, sprintf(sprintf("%${i}s", sprintf("%s", trim($sl[$n])))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print("\n");
|
push(@output, "\n");
|
||||||
print("Time$line2\n");
|
push(@output, "Time$line2\n");
|
||||||
print("----$line3 \n");
|
push(@output, "----$line3 \n");
|
||||||
my $line;
|
my $line;
|
||||||
my @row;
|
my @row;
|
||||||
my $time;
|
my $time;
|
||||||
|
@ -312,7 +313,7 @@ sub ipmi_cgi {
|
||||||
for($n = 0, $time = $tf->{tb}; $n < ($tf->{tb} * $tf->{ts}); $n++) {
|
for($n = 0, $time = $tf->{tb}; $n < ($tf->{tb} * $tf->{ts}); $n++) {
|
||||||
$line = @$data[$n];
|
$line = @$data[$n];
|
||||||
$time = $time - (1 / $tf->{ts});
|
$time = $time - (1 / $tf->{ts});
|
||||||
printf(" %2d$tf->{tc} ", $time);
|
push(@output, sprintf(" %2d$tf->{tc} ", $time));
|
||||||
for($n2 = 0; $n2 < scalar(my @sl = split(',', $ipmi->{list})); $n2++) {
|
for($n2 = 0; $n2 < scalar(my @sl = split(',', $ipmi->{list})); $n2++) {
|
||||||
$n3 = 0;
|
$n3 = 0;
|
||||||
foreach my $i (split(',', $ipmi->{desc}->{$n2})) {
|
foreach my $i (split(',', $ipmi->{desc}->{$n2})) {
|
||||||
|
@ -320,19 +321,19 @@ sub ipmi_cgi {
|
||||||
$to = $from + 1;
|
$to = $from + 1;
|
||||||
my ($j) = @$line[$from..$to];
|
my ($j) = @$line[$from..$to];
|
||||||
@row = ($j);
|
@row = ($j);
|
||||||
printf("%7.1lf ", @row);
|
push(@output, sprintf("%7.1lf ", @row));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print("\n");
|
push(@output, "\n");
|
||||||
}
|
}
|
||||||
print(" </pre>\n");
|
push(@output, " </pre>\n");
|
||||||
if($title) {
|
if($title) {
|
||||||
print(" </td>\n");
|
push(@output, " </td>\n");
|
||||||
print(" </tr>\n");
|
push(@output, " </tr>\n");
|
||||||
main::graph_footer();
|
push(@output, main::graph_footer());
|
||||||
}
|
}
|
||||||
print(" <br>\n");
|
push(@output, " <br>\n");
|
||||||
return;
|
return @output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -363,14 +364,14 @@ sub ipmi_cgi {
|
||||||
while($n < scalar(my @sl = split(',', $ipmi->{list}))) {
|
while($n < scalar(my @sl = split(',', $ipmi->{list}))) {
|
||||||
if($title) {
|
if($title) {
|
||||||
if($n == 0) {
|
if($n == 0) {
|
||||||
main::graph_header($title, $ipmi->{graphs_per_row});
|
push(@output, main::graph_header($title, $ipmi->{graphs_per_row}));
|
||||||
}
|
}
|
||||||
print(" <tr>\n");
|
push(@output, " <tr>\n");
|
||||||
}
|
}
|
||||||
for($n2 = 0; $n2 < $ipmi->{graphs_per_row}; $n2++) {
|
for($n2 = 0; $n2 < $ipmi->{graphs_per_row}; $n2++) {
|
||||||
last unless $n < scalar(my @sl = split(',', $ipmi->{list}));
|
last unless $n < scalar(my @sl = split(',', $ipmi->{list}));
|
||||||
if($title) {
|
if($title) {
|
||||||
print(" <td bgcolor='" . $colors->{title_bg_color} . "'>\n");
|
push(@output, " <td bgcolor='" . $colors->{title_bg_color} . "'>\n");
|
||||||
}
|
}
|
||||||
undef(@tmp);
|
undef(@tmp);
|
||||||
undef(@tmpz);
|
undef(@tmpz);
|
||||||
|
@ -422,7 +423,7 @@ sub ipmi_cgi {
|
||||||
@CDEF,
|
@CDEF,
|
||||||
@tmp);
|
@tmp);
|
||||||
$err = RRDs::error;
|
$err = RRDs::error;
|
||||||
print("ERROR: while graphing $IMG_DIR" . "$IMG[$n]: $err\n") if $err;
|
push(@output, "ERROR: while graphing $IMG_DIR" . "$IMG[$n]: $err\n") if $err;
|
||||||
if(lc($config->{enable_zoom}) eq "y") {
|
if(lc($config->{enable_zoom}) eq "y") {
|
||||||
($width, $height) = split('x', $config->{graph_size}->{zoom});
|
($width, $height) = split('x', $config->{graph_size}->{zoom});
|
||||||
$picz = $rrd{$version}->("$IMG_DIR" . "$IMGz[$n]",
|
$picz = $rrd{$version}->("$IMG_DIR" . "$IMGz[$n]",
|
||||||
|
@ -450,12 +451,12 @@ sub ipmi_cgi {
|
||||||
@CDEF,
|
@CDEF,
|
||||||
@tmpz);
|
@tmpz);
|
||||||
$err = RRDs::error;
|
$err = RRDs::error;
|
||||||
print("ERROR: while graphing $IMG_DIR" . "$IMGz[$n]: $err\n") if $err;
|
push(@output, "ERROR: while graphing $IMG_DIR" . "$IMGz[$n]: $err\n") if $err;
|
||||||
}
|
}
|
||||||
if($title || ($silent =~ /imagetag/ && $graph =~ /ipmi$n/)) {
|
if($title || ($silent =~ /imagetag/ && $graph =~ /ipmi$n/)) {
|
||||||
if(lc($config->{enable_zoom}) eq "y") {
|
if(lc($config->{enable_zoom}) eq "y") {
|
||||||
if(lc($config->{disable_javascript_void}) eq "y") {
|
if(lc($config->{disable_javascript_void}) eq "y") {
|
||||||
print(" <a href=\"" . $config->{url} . "/" . $config->{imgs_dir} . $IMGz[$n] . "\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $IMG[$n] . "' border='0'></a>\n");
|
push(@output, " <a href=\"" . $config->{url} . "/" . $config->{imgs_dir} . $IMGz[$n] . "\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $IMG[$n] . "' border='0'></a>\n");
|
||||||
} else {
|
} else {
|
||||||
if($version eq "new") {
|
if($version eq "new") {
|
||||||
$picz_width = $picz->{image_width} * $config->{global_zoom};
|
$picz_width = $picz->{image_width} * $config->{global_zoom};
|
||||||
|
@ -464,26 +465,26 @@ sub ipmi_cgi {
|
||||||
$picz_width = $width + 115;
|
$picz_width = $width + 115;
|
||||||
$picz_height = $height + 100;
|
$picz_height = $height + 100;
|
||||||
}
|
}
|
||||||
print(" <a href=\"javascript:void(window.open('" . $config->{url} . "/" . $config->{imgs_dir} . $IMGz[$n] . "','','width=" . $picz_width . ",height=" . $picz_height . ",scrollbars=0,resizable=0'))\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $IMG[$n] . "' border='0'></a>\n");
|
push(@output, " <a href=\"javascript:void(window.open('" . $config->{url} . "/" . $config->{imgs_dir} . $IMGz[$n] . "','','width=" . $picz_width . ",height=" . $picz_height . ",scrollbars=0,resizable=0'))\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $IMG[$n] . "' border='0'></a>\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print(" <img src='" . $config->{url} . "/" . $config->{imgs_dir} . $IMG[$n] . "'>\n");
|
push(@output, " <img src='" . $config->{url} . "/" . $config->{imgs_dir} . $IMG[$n] . "'>\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($title) {
|
if($title) {
|
||||||
print(" </td>\n");
|
push(@output, " </td>\n");
|
||||||
}
|
}
|
||||||
$n++;
|
$n++;
|
||||||
}
|
}
|
||||||
if($title) {
|
if($title) {
|
||||||
print(" </tr>\n");
|
push(@output, " </tr>\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($title) {
|
if($title) {
|
||||||
main::graph_footer();
|
push(@output, main::graph_footer());
|
||||||
}
|
}
|
||||||
print(" <br>\n");
|
push(@output, " <br>\n");
|
||||||
return;
|
return @output;
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
Loading…
Reference in New Issue