diff --git a/Changes b/Changes index 941e266..40c1d62 100644 --- a/Changes +++ b/Changes @@ -21,6 +21,8 @@ signal. This should also fix sporadic hangups in the HTTP and a truncation in the rotated logfile. - Added in 'du.pm' the ability to count files in every directory defined. [#112] +- Added the ability to show all graphs of a single server in Multihost mode, + instead of showing only the System Load graph. [#216] - Fixed a bad memory scaling in *BSD systems. - Fixed in 'process.pm' to fully honour the option 'netstats_in_bps'. - Fixed to force Monitorix to be started at the end of boot in systemd-based diff --git a/monitorix.cgi b/monitorix.cgi index 7778f54..fb1e456 100755 --- a/monitorix.cgi +++ b/monitorix.cgi @@ -2,7 +2,7 @@ # # Monitorix - A lightweight system monitoring tool. # -# Copyright (C) 2005-2017 by Jordi Sanfeliu +# Copyright (C) 2005-2019 by Jordi Sanfeliu # # 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 @@ -139,31 +139,35 @@ sub multihost { print "
\n"; } } else { - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - if(lc($multihost->{footer_url}) eq "y") { - print " \n"; + if($cgi->{graph} eq "all") { + print " \n"; + } else { + print "
\n"; - print " \n"; - print "   " . $host[$cgi->{val}] . "\n"; - print " \n"; - print "
\n"; - print " \n"; - print "
\n"; - print " \n"; - print " \n"; - print "   $foot_url[$cgi->{val}]\n"; - print " \n"; - print "
\n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + if(lc($multihost->{footer_url}) eq "y") { + print " \n"; + } + print " \n"; + print "
\n"; + print " \n"; + print "   " . $host[$cgi->{val}] . "\n"; + print " \n"; + print "
\n"; + print " \n"; + print "
\n"; + print " \n"; + print " \n"; + print "   $foot_url[$cgi->{val}]\n"; + print " \n"; + print "
\n"; + print "
\n"; } - print " \n"; - print " \n"; - print "
\n"; } } @@ -412,6 +416,7 @@ if($RRDs::VERSION > 1.2) { if(!$silent) { my $title; my $str; + my @output; my $piwik_code = ""; my ($piwik_url, $piwik_sid, $piwik_img); @@ -456,65 +461,73 @@ EOF print(" \n"); print(" $piwik_code\n"); print("
\n"); - print(" \n"); - print(" \n"); + push(@output, "
\n"); + push(@output, " \n"); if(lc($config{enable_back_button} || "") eq "y") { - print(" \n"); + push(@output, " \n"); } if(($val ne "all" || $val ne "group") && $mode ne "multihost") { - print(" \n"); + push(@output, " \n"); } if($val =~ m/group(\d+)/) { my $gnum = $1; my $gname = (split(',', $config{multihost}->{remotegroup_list}))[$gnum]; $gname = trim($gname); - print(" \n"); + push(@output, " \n"); } - print(" \n"); - print(" \n"); - print(" \n"); - print("
\n"); - print(" \n"); - print("   Host: \n"); - print(" \n"); - print(" \n"); + push(@output, " \n"); + push(@output, "   Host: \n"); + push(@output, " \n"); + push(@output, " \n"); - print(" \n"); - print("   $gname \n"); - print(" \n"); - print(" \n"); + push(@output, " \n"); + push(@output, "   $gname \n"); + push(@output, " \n"); + push(@output, " \n"); - print(" \n"); + push(@output, " \n"); + push(@output, " \n"); if($mode eq "localhost" || $mode eq "traffacct") { $title = $config{hostname}; } elsif($mode eq "multihost") { - $graph = $graph eq "all" ? "_system1" : $graph; - my ($g1, $g2) = ($graph =~ /(_\D+).*?(\d)$/); - if($g1 eq "_port") { - $title = $config{graphs}->{$g1}; - $g2 = trim((split(',', $config{port}->{list}))[$g2]); - $title .= " " . $g2; - $g2 = (split(',', $config{port}->{desc}->{$g2}))[0]; - $title .= " (" . trim($g2) . ")"; +# $graph = $graph eq "all" ? "_system1" : $graph; + if($graph ne "all") { + my ($g1, $g2) = ($graph =~ /(_\D+).*?(\d)$/); + if($g1 eq "_port") { + $title = $config{graphs}->{$g1}; + $g2 = trim((split(',', $config{port}->{list}))[$g2]); + $title .= " " . $g2; + $g2 = (split(',', $config{port}->{desc}->{$g2}))[0]; + $title .= " (" . trim($g2) . ")"; + } else { + $g2 = "" if $g1 eq "_proc"; # '_procn' must be converted to '_proc' + $title = $config{graphs}->{$g1 . $g2}; + } } else { - $g2 = "" if $g1 eq "_proc"; # '_procn' must be converted to '_proc' - $title = $config{graphs}->{$g1 . $g2}; + $title = $graph eq "all" ? $config{graphs}->{_system1} : $graph; } } $title =~ s/ / /g; my $twhen = $tf{nwhen} > 1 ? "$tf{nwhen} $tf{twhen}" : $tf{twhen}; $twhen .= "s" if $tf{nwhen} > 1; - print("   $title  \n"); - print(" \n"); - print(" \n"); - print(" \n"); - print("   last $twhen  \n"); + + if($mode ne "multihost" || $graph ne "all" || $val eq "all") { + print @output; + print("   $title  \n"); print(" \n"); print("
\n"); - print(" \n"); - print encode('utf-8', "

" . strftime("%a %b %e %H:%M:%S %Z %Y", localtime) . "

\n"); + print(" \n"); + print(" \n"); + print("   last $twhen  \n"); + print(" \n"); + print(" \n"); + print(" \n"); + print(" \n"); + print(" \n"); + print encode('utf-8', "

" . strftime("%a %b %e %H:%M:%S %Z %Y", localtime) . "

\n"); + } } @@ -623,16 +636,18 @@ if($mode eq "localhost") { } if(!$silent) { - print("\n"); - print("
\n"); - print("
\n"); - print("\n"); - print("

\n"); - print(" \n"); - print("
\n"); - print(" \n"); - print("Copyright © 2005-2017 Jordi Sanfeliu\n"); - print(" \n"); + if($mode ne "multihost" || $graph ne "all" || $val eq "all") { + print("\n"); + print("
\n"); + print(" \n"); + print("\n"); + print("

\n"); + print(" \n"); + print("
\n"); + print(" \n"); + print("Copyright © 2005-2017 Jordi Sanfeliu\n"); + print(" \n"); + } print(" \n"); print("\n"); print("\n");