Server Status Total Bandwidth

I’ll take a stab at it tonight and fork your project + PR the changes.

1 Like

If you have the time i would definitly love it but don’t feel the urge at all to do it.

I am really thankful if you do work on it. :+1: :+1: :+1: :+1:

Everything is in this specfic folder if needed ServerStatus/status at master · IIPoliII/ServerStatus · GitHub

This should work now, there was a pesky - in the way, plus some other bugs.

function total_network() {
	var bw_in_total = 0;
	var bw_out_total = 0;
	var bw_in = 0;
	var bw_out = 0;
	var bw_in_size;
	var bw_out_size;
	var cnt = 0;
	
	$('[id="network"]').each(function() {
		cnt++
		if((cnt > 1) && ($(this).text() != "–")) {
			// IN
			bw_in = $(this).text().split("|")[0];
			bw_in_size = bw_in.slice(-1);
			bw_in = bw_in.slice(0, -1);
			if(bw_in_size == 'K') {bw_in *= 1000;}
			if(bw_in_size == 'M') {bw_in *= 1000000;}
			bw_in_total = parseInt(bw_in_total) + parseInt(bw_in); // Ttoal in B
			// OUT
			bw_out = $(this).text().split("|")[1];
			bw_out_size = bw_out.slice(-1);
			bw_out = bw_out.slice(0, -1);
			if(bw_out_size == 'K') {bw_out *= 1000;}
			if(bw_out_size == 'M') {bw_out *= 1000000;}
			bw_out_total = parseInt(bw_out_total) + parseInt(bw_out); // Ttoal in B
		}
	});
	// Debug
	console.log('Total BW In: ' + bw_in_total);
	console.log('Total BW Out: ' + bw_out_total);

	// Insert values into element
	$('#TotalBandwidthIn').text('Total Bandwidth In: ' + bw_in_total);
	$('#TotalBandwidthOut').text('Total Bandwidth Out: ' + bw_out_total);
}

But as @Manson said this is a “cosmetic” hack, you would be better off just coding something else in the back-end using the data straight from the stats json. I chose this method because it’s the simplest without having to go through the actual code of your status page and figure out what is where.

Yeah i see what you mean i will try to add it temporary just to see how it works out ! Thanks for the little code c:

Well this tiny hack worked i will do a little conversion in kb and in mb while mason works on the best version possible c:

EDIT : did worked out https://poli.network/

Implemented in a PR to your repo -

Didn’t really do much design, just used what was available. Here’s what it looks like -

image

Live example of it on my status site - https://status.rowe.sh/

1 Like

Awesome! :grin: really perfect!

I will directly merge it C: and try it out

1 Like