Extended the features of multiple-servers in Multihost mode

Added the ability to show all graphs (side-by-side) of all remote servers instead of showing
only the System Load graph.

#216
This commit is contained in:
Jordi Sanfeliu 2019-01-03 09:27:48 +01:00
parent 4c1f1e28ec
commit b847924d8c
1 changed files with 72 additions and 39 deletions

View File

@ -94,6 +94,38 @@ sub multihost {
my $graph = ($cgi->{graph} eq "all" || $cgi->{graph} =~ m/group\[0-9]*/) ? "_system1" : $cgi->{graph};
if($cgi->{val} eq "all" || $cgi->{val} =~ m/group[0-9]*/) {
if($cgi->{graph} eq "all") {
print "<table cellspacing='5' cellpadding='0' width='1' bgcolor='$colors->{graph_bg_color}' border='1'>\n";
my $g = 0;
foreach (split(',', $config{graph_name})) {
my $gn = trim($_);
if(lc($config{graph_enable}->{$gn}) eq "y") {
if(!$g) {
print " <tr>\n";
for($n = 0; $n < scalar(@host); $n++) {
print " <td bgcolor='$colors->{title_bg_color}'>\n";
print " <font face='Verdana, sans-serif' color='$colors->{fg_color}'>\n";
print " <b>&nbsp;&nbsp;" . $host[$n] . "</b>\n";
print " </font>\n";
print " </td>\n";
}
print " </tr>\n";
}
print " <tr>\n";
for(my $sg = 1; $config{graphs}->{"_$gn$sg"}; $sg++) {
for($n = 0; $n < scalar(@host); $n++) {
print " <td bgcolor='$colors->{title_bg_color}' style='vertical-align: top; height: 10%; width: 10%;'>\n";
print " <iframe src='" . $url[$n] . "/monitorix.cgi?mode=localhost&when=$cgi->{when}&graph=_${gn}$sg&color=$cgi->{color}&silent=imagetag' height=201 width=397 frameborder=0 marginwidth=0 marginheight=0 scrolling=no></iframe>\n";
print " </td>\n";
}
print " </tr>\n";
}
}
$g++;
}
print "</table>\n";
print "<br>\n";
} else {
for($n = 0; $n < scalar(@host); $n += $multihost->{graphs_per_row}) {
print "<table cellspacing='5' cellpadding='0' width='1' bgcolor='$colors->{graph_bg_color}' border='1'>\n";
print " <tr>\n";
@ -138,6 +170,7 @@ sub multihost {
print "</table>\n";
print "<br>\n";
}
}
} else {
if($cgi->{graph} eq "all") {
print " <iframe src='" . (split(',', $multihost->{remotehost_desc}->{$cgi->{val}}))[0] . (split(',', $multihost->{remotehost_desc}->{$cgi->{val}}))[2] . "/monitorix.cgi?mode=localhost&when=$cgi->{when}&graph=all&color=$cgi->{color}' height=100% width=100% frameborder=0 marginwidth=0 marginheight=0 scrolling=yes></iframe>\n";
@ -505,7 +538,7 @@ EOF
$title = $config{graphs}->{$g1 . $g2};
}
} else {
$title = $graph eq "all" ? $config{graphs}->{_system1} : $graph;
$title = $graph eq "all" ? "all graphs" : $graph;
}
}
$title =~ s/ /&nbsp;/g;