From b847924d8ca59552946ff53f8cca0f0efe053848 Mon Sep 17 00:00:00 2001 From: Jordi Sanfeliu Date: Thu, 3 Jan 2019 09:27:48 +0100 Subject: [PATCH] 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 --- monitorix.cgi | 111 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 72 insertions(+), 39 deletions(-) diff --git a/monitorix.cgi b/monitorix.cgi index 07e8dd3..b0249f1 100755 --- a/monitorix.cgi +++ b/monitorix.cgi @@ -94,49 +94,82 @@ 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]*/) { - for($n = 0; $n < scalar(@host); $n += $multihost->{graphs_per_row}) { + if($cgi->{graph} eq "all") { print "\n"; - print " \n"; - for($n2 = 0; $n2 < $multihost->{graphs_per_row}; $n2++) { - if($n < scalar(@host)) { - print " \n"; + my $g = 0; + foreach (split(',', $config{graph_name})) { + my $gn = trim($_); + if(lc($config{graph_enable}->{$gn}) eq "y") { + if(!$g) { + print " \n"; + for($n = 0; $n < scalar(@host); $n++) { + print " \n"; + } + print " \n"; + } + print " \n"; + for(my $sg = 1; $config{graphs}->{"_$gn$sg"}; $sg++) { + for($n = 0; $n < scalar(@host); $n++) { + print " \n"; + } + print " \n"; + } } - $n++; + $g++; } - print " \n"; - print " \n"; - for($n2 = 0, $n = $n - $multihost->{graphs_per_row}; $n2 < $multihost->{graphs_per_row}; $n2++) { - if($n < scalar(@host)) { - print " \n"; - - } - $n++; - } - print " \n"; - print " \n"; - for($n2 = 0, $n = $n - $multihost->{graphs_per_row}; $n2 < $multihost->{graphs_per_row}; $n2++) { - if($n < scalar(@host)) { - if(lc($multihost->{footer_url}) eq "y") { - print " \n"; - } - } - $n++; - } - $n = $n - $multihost->{graphs_per_row}; - print " \n"; print "
\n"; - print " \n"; - print "   " . $host[$n] . "\n"; - print " \n"; - print "
\n"; + print " \n"; + print "   " . $host[$n] . "\n"; + print " \n"; + print "
\n"; + print " \n"; + print "
\n"; - print " \n"; - print "
\n"; - print " \n"; - print " \n"; - print "   $foot_url[$n]\n"; - print " \n"; - print "
\n"; print "
\n"; + } else { + for($n = 0; $n < scalar(@host); $n += $multihost->{graphs_per_row}) { + print "\n"; + print " \n"; + for($n2 = 0; $n2 < $multihost->{graphs_per_row}; $n2++) { + if($n < scalar(@host)) { + print " \n"; + } + $n++; + } + print " \n"; + print " \n"; + for($n2 = 0, $n = $n - $multihost->{graphs_per_row}; $n2 < $multihost->{graphs_per_row}; $n2++) { + if($n < scalar(@host)) { + print " \n"; + + } + $n++; + } + print " \n"; + print " \n"; + for($n2 = 0, $n = $n - $multihost->{graphs_per_row}; $n2 < $multihost->{graphs_per_row}; $n2++) { + if($n < scalar(@host)) { + if(lc($multihost->{footer_url}) eq "y") { + print " \n"; + } + } + $n++; + } + $n = $n - $multihost->{graphs_per_row}; + print " \n"; + print "
\n"; + print " \n"; + print "   " . $host[$n] . "\n"; + print " \n"; + print "
\n"; + print " \n"; + print "
\n"; + print " \n"; + print " \n"; + print "   $foot_url[$n]\n"; + print " \n"; + print "
\n"; + print "
\n"; + } } } else { if($cgi->{graph} eq "all") { @@ -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/ / /g;