1
0
mirror of https://github.com/mailcow/mailcow-dockerized.git synced 2024-12-04 10:24:42 +02:00

[BS5] adjust host stats

This commit is contained in:
FreddleSpl0it 2022-08-10 10:56:10 +02:00
parent a3c0737ba8
commit ea21bca7df
4 changed files with 37 additions and 26 deletions

View File

@ -1077,6 +1077,19 @@ function formatUptime(seconds){
var sFormat = s > 0 ? s + "S" : ""; var sFormat = s > 0 ? s + "S" : "";
return dFormat + hFormat + mFormat + sFormat; return dFormat + hFormat + mFormat + sFormat;
} }
// format bytes to readable string
function formatBytes(bytes){
// b
if (bytes < 1000) return bytes.toFixed(2).toString()+' B/s';
// b to kb
bytes = bytes / 1024;
if (bytes < 1000) return bytes.toFixed(2).toString()+' KB/s';
// kb to mb
bytes = bytes / 1024;
if (bytes < 1000) return bytes.toFixed(2).toString()+' MB/s';
// final mb to gb
return (bytes / 1024).toFixed(2).toString()+' GB/s';
}
// create network and disk chart // create network and disk chart
function createNetAndDiskChart(){ function createNetAndDiskChart(){
var net_io_ctx = document.getElementById("net_io_chart"); var net_io_ctx = document.getElementById("net_io_chart");
@ -1088,7 +1101,8 @@ function createNetAndDiskChart(){
label: "Recieve", label: "Recieve",
backgroundColor: "rgba(41, 187, 239, 0.3)", backgroundColor: "rgba(41, 187, 239, 0.3)",
borderColor: "rgba(41, 187, 239, 0.6)", borderColor: "rgba(41, 187, 239, 0.6)",
color: "#ff0000", pointRadius: 1,
pointHitRadius: 6,
borderWidth: 2, borderWidth: 2,
fill: true, fill: true,
tension: 0.2, tension: 0.2,
@ -1097,6 +1111,8 @@ function createNetAndDiskChart(){
label: "Sent", label: "Sent",
backgroundColor: "rgba(239, 60, 41, 0.3)", backgroundColor: "rgba(239, 60, 41, 0.3)",
borderColor: "rgba(239, 60, 41, 0.6)", borderColor: "rgba(239, 60, 41, 0.6)",
pointRadius: 1,
pointHitRadius: 6,
borderWidth: 2, borderWidth: 2,
fill: true, fill: true,
tension: 0.2, tension: 0.2,
@ -1104,6 +1120,9 @@ function createNetAndDiskChart(){
}] }]
}; };
var optionsNet = { var optionsNet = {
interaction: {
mode: 'index'
},
scales: { scales: {
yAxis: { yAxis: {
min: 0, min: 0,
@ -1112,16 +1131,7 @@ function createNetAndDiskChart(){
}, },
ticks: { ticks: {
callback: function(i, index, ticks) { callback: function(i, index, ticks) {
// b return formatBytes(i);
if (i < 1000) return i.toFixed(2).toString()+' B/s';
// b to kb
i = i / 1024;
if (i < 1000) return i.toFixed(2).toString()+' KB/s';
// kb to mb
i = i / 1024;
if (i < 1000) return i.toFixed(2).toString()+' MB/s';
// final mb to gb
return (i / 1024).toFixed(2).toString()+' GB/s';
} }
} }
}, },
@ -1139,7 +1149,8 @@ function createNetAndDiskChart(){
label: "Read", label: "Read",
backgroundColor: "rgba(41, 187, 239, 0.3)", backgroundColor: "rgba(41, 187, 239, 0.3)",
borderColor: "rgba(41, 187, 239, 0.6)", borderColor: "rgba(41, 187, 239, 0.6)",
color: "#ff0000", pointRadius: 1,
pointHitRadius: 6,
borderWidth: 2, borderWidth: 2,
fill: true, fill: true,
tension: 0.2, tension: 0.2,
@ -1148,6 +1159,8 @@ function createNetAndDiskChart(){
label: "Write", label: "Write",
backgroundColor: "rgba(239, 60, 41, 0.3)", backgroundColor: "rgba(239, 60, 41, 0.3)",
borderColor: "rgba(239, 60, 41, 0.6)", borderColor: "rgba(239, 60, 41, 0.6)",
pointRadius: 1,
pointHitRadius: 6,
borderWidth: 2, borderWidth: 2,
fill: true, fill: true,
tension: 0.2, tension: 0.2,
@ -1155,6 +1168,9 @@ function createNetAndDiskChart(){
}] }]
}; };
var optionsDisk = { var optionsDisk = {
interaction: {
mode: 'index'
},
scales: { scales: {
yAxis: { yAxis: {
min: 0, min: 0,
@ -1163,16 +1179,7 @@ function createNetAndDiskChart(){
}, },
ticks: { ticks: {
callback: function(i, index, ticks) { callback: function(i, index, ticks) {
// b return formatBytes(i);
if (i < 1000) return i.toFixed(2).toString()+' B/s';
// b to kb
i = i / 1024;
if (i < 1000) return i.toFixed(2).toString()+' KB/s';
// kb to mb
i = i / 1024;
if (i < 1000) return i.toFixed(2).toString()+' MB/s';
// final mb to gb
return (i / 1024).toFixed(2).toString()+' GB/s';
} }
} }
}, },
@ -1228,12 +1235,12 @@ function check_update(current_version, github_repo_url){
// err // err
console.log(err); console.log(err);
$("#mailcow_update").removeClass("text-success text-warning").addClass("text-danger"); $("#mailcow_update").removeClass("text-success text-warning").addClass("text-danger");
$("#mailcow_update").html("<b>Could not check for an Update</b>"); $("#mailcow_update").html("<b>"+ lang_debug.update_failed +"</b>");
}); });
}).catch(err => { }).catch(err => {
// err // err
console.log(err); console.log(err);
$("#mailcow_update").removeClass("text-success text-warning").addClass("text-danger"); $("#mailcow_update").removeClass("text-success text-warning").addClass("text-danger");
$("#mailcow_update").html("<b>Could not check for an Update</b>"); $("#mailcow_update").html("<b>"+ lang_debug.update_failed +"</b>");
}); });
} }

View File

@ -521,6 +521,7 @@
"uptime": "Uptime", "uptime": "Uptime",
"update_available": "Es ist ein Update verfügbar", "update_available": "Es ist ein Update verfügbar",
"no_update_available": "Das System ist auf aktuellem Stand", "no_update_available": "Das System ist auf aktuellem Stand",
"update_failed": "Es konnte nicht nach einem Update gesucht werden",
"username": "Benutzername" "username": "Benutzername"
}, },
"diagnostics": { "diagnostics": {

View File

@ -521,6 +521,7 @@
"uptime": "Uptime", "uptime": "Uptime",
"update_available": "There is an update available", "update_available": "There is an update available",
"no_update_available": "The System is on the latest version", "no_update_available": "The System is on the latest version",
"update_failed": "Could not check for an Update",
"username": "Username" "username": "Username"
}, },
"diagnostics": { "diagnostics": {

View File

@ -102,10 +102,12 @@
</div> </div>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6 mt-4">
<h3>Network I/O</h3>
<canvas id="net_io_chart" width="400" height="200"></canvas> <canvas id="net_io_chart" width="400" height="200"></canvas>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6 mt-4">
<h3>Disk I/O</h3>
<canvas id="disk_io_chart" width="400" height="200"></canvas> <canvas id="disk_io_chart" width="400" height="200"></canvas>
</div> </div>