Statistics page for VPS fails to load due to an error under certain conditions

Hello everyone,

We were making sure that the statistics and reporting was displaying accurate information for clients. When we turned on all the statistics in the screenshot attached, everything worked as expected. As soon as we ticked anything additional to display such as Memory usage.. we receive the following error in the console:

bundle.min.js?19469999999999901:2 Uncaught ReferenceError: value3 is not defined at onLoad (one_history.cgi?id=1584549160289670&start=1584988509&period=86400&stat=cpuio&stat=cpuidle&stat=cpukernel&stat=load&stat=load15&stat=load5&stat=cpuuser&stat=memcached&stat=bin&stat=bout&stat=diskfree&stat=diskused&stat=diskratio&stat=memfree&stat=memtotal&stat=memratio&logscale=1:211) at Object.snippets.page.render (bundle.min.js?19469999999999901:249) at HTMLDocument. (bundle.min.js?19469999999999901:255) at l (bundle.min.js?19469999999999901:2) at c (bundle.min.js?19469999999999901:2)

Issue is not dependant on linear or logarithmic X/Y scaling.

The page remains gray and does not load. Please help, we need clients to be able to view all their statistics. Looking forward to hearing back from you guys.

Status: 
Fixed (pending)

Comments

thedaemexco's picture
Submitted by thedaemexco on Tue, 03/24/2020 - 13:55 Pro Licensee

Title: Statistics graph for VPS fails to load due to an error under certain conditions ยป Statistics page for VPS fails to load due to an error under certain conditions
Ilia's picture
Submitted by Ilia on Tue, 03/24/2020 - 16:34

Status:
Active
»
Fixed (pending)

Hi,

Thanks for reporting. I have fixed that issue on our repos but you would have manually open:

/usr/libexec/webmin/server-manager/one_history.cgi

and move

$stat_to_axis{$stat} = "value".$axis;

..one line up, so it looks like this:

print "        $maxopt\n";
		print "        min: 0\n";
		print "      });\n";
		$stat_to_axis{$stat} = "value".$axis;
		}
	}

# Generate JS for each stat
Ilia's picture
Submitted by Ilia on Tue, 03/24/2020 - 16:38

Status:
Fixed (pending)
»
Needs work

..I given that more tests and it seems incorrect. :(

I will have a closer look tomorrow.

Ilia's picture
Submitted by Ilia on Tue, 03/24/2020 - 17:12

Status:
Needs work
»
Fixed (pending)

Okay, fixed finally.

Jamie, I don't see how would that be possible to make it work otherwise. Some data cannot be combined. At the same time it satisfies Timeplot and that's okay for now.

@thedaemexco

To fix this, find in earlier mentioned file:

foreach $stat (@stats) {
	$maxopt = "";
	$fmt = &historic_stat_info($stat, $maxes);
	if ($maxes->{$stat}) {
		$maxv = $maxes->{$stat};
		$maxv /= $fmt->{'scale'} if ($fmt && $fmt->{'scale'});
		$maxopt = "max: $maxv,";
		}
	$units = $fmt ? $fmt->{'units'} : "count";
	$axis = &indexof($units, @axes);
	if ($axis < 0) {
		# New axis
		$axis = scalar(@axes);
		push(@axes, $units);
		if ($axis == 0) {
			$place = "left";
			}
		elsif ($axis == 1) {
			$place = "right";
			}
		else {
			next;
			}
		print "var value$axis = new Timeplot.$geom({\n";
		print "        gridColor: '#B3B6B0',\n";
		print "        axisLabelsPlacement: '$place',\n";
		print "        $maxopt\n";
		print "        min: 0\n";
		print "      });\n";
		}
	$stat_to_axis{$stat} = "value".$axis;
	}

.. and replace with:

my $ii = 0;
foreach $stat (@stats) {
	$maxopt = "";
	$fmt = &historic_stat_info($stat, $maxes);
	if ($maxes->{$stat}) {
		$maxv = $maxes->{$stat};
		$maxv /= $fmt->{'scale'} if ($fmt && $fmt->{'scale'});
		$maxopt = "max: $maxv,";
		}
	$units = $fmt ? $fmt->{'units'} : "count";
	$axis = &indexof($units, @axes);
	if ($axis < 0) {
		# New axis
		$axis = scalar(@axes);
		push(@axes, $units);
		if ($axis == 0) {
			$place = "left";
			}
		elsif ($axis == 1) {
			$place = "right";
			}
		else {
			next;
			}
		}
		print "var value${axis}${ii} = new Timeplot.$geom({\n";
		print "        gridColor: '#B3B6B0',\n";
		print "        axisLabelsPlacement: '$place',\n";
		print "        $maxopt\n";
		print "        min: 0\n";
		print "      });\n";
	$stat_to_axis{$stat} = "value${axis}${ii}";
	$ii++;
	}

Ilia - what two kinds of stats cannot be combined in this case?

I can't see how that code change would help, because $stat and $axis are going to end up with the same values regardless.

thedaemexco's picture
Submitted by thedaemexco on Tue, 03/24/2020 - 22:52 Pro Licensee

Hello guys, thank you for the response. We will attempt the code change and let you guys know what happens. If there is anything else on your end, please feel free to share. Thanks!

Ilia's picture
Submitted by Ilia on Wed, 03/25/2020 - 07:09

I can't see how that code change would help, because $stat and $axis are going to end up with the same values regardless.

Not exactly, there is valueX clash.

Try selecting the following or use this URL to see how it fails with an old code:

one_history.cgi?id=0&start=1585040701&period=86400&stat=cpuio&stat=load&stat=diskratio&stat=memfree&stat=memtotal&logscale=0

or select at the same time:

CPU IO wait time, Disk used percent, Memory free, Memory limit.

The same happened on Virtualmin.

thedaemexco's picture
Submitted by thedaemexco on Wed, 03/25/2020 - 20:25 Pro Licensee

Hello team, we can confirm that the changes made according to comment #6 has resolved the issue! Much appreciated. This issue can be closed. Stay safe out there guys!

Odd, I wasn't able to reproduce this - bug if it works, great! Ilia, can you check this fix in?

Ilia's picture
Submitted by Ilia on Thu, 03/26/2020 - 04:26

Odd, I wasn't able to reproduce this - bug if it works, great!

Jamie, try to pick more stats to display at one time.

Ilia, can you check this fix in?

Yes, Jamie, I already did @fcab395 and @7f9ef49