From 654ecd7a3e266cbb64f001fef6915a28ac8c8af6 Mon Sep 17 00:00:00 2001 From: cppla Date: Fri, 1 Apr 2022 15:50:09 +0800 Subject: [PATCH] update disk io style --- clients/client-linux.py | 2 +- clients/client-psutil.py | 2 +- web/css/dark.css | 1 + web/css/light.css | 1 + web/js/serverstatus.js | 14 +++++++++++--- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/clients/client-linux.py b/clients/client-linux.py index 301231e..235c734 100755 --- a/clients/client-linux.py +++ b/clients/client-linux.py @@ -307,7 +307,7 @@ def get_realtime_data(): target=_net_speed, ) t5 = threading.Thread( - target=_disk_io(), + target=_disk_io, ) for ti in [t1, t2, t3, t4, t5]: ti.setDaemon(True) diff --git a/clients/client-psutil.py b/clients/client-psutil.py index f8e88fa..5f1b58b 100755 --- a/clients/client-psutil.py +++ b/clients/client-psutil.py @@ -277,7 +277,7 @@ def get_realtime_data(): target=_net_speed, ) t5 = threading.Thread( - target=_disk_io(), + target=_disk_io, ) for ti in [t1, t2, t3, t4, t5]: ti.setDaemon(True) diff --git a/web/css/dark.css b/web/css/dark.css index 2211a84..ac3c35b 100644 --- a/web/css/dark.css +++ b/web/css/dark.css @@ -20,6 +20,7 @@ tr.odd.expandRow > :hover { background: #212e36 !important; } #month_traffic { min-width: 85px; max-width: 95px;} #network { min-width: 115px; } #cpu, #ram, #hdd { min-width: 45px; max-width: 90px; } +#io { min-width: 55px; } #ping { max-width: 95px; } @media only screen and (max-width: 1080px) { diff --git a/web/css/light.css b/web/css/light.css index 3d6e11d..9765fa3 100644 --- a/web/css/light.css +++ b/web/css/light.css @@ -17,6 +17,7 @@ tr.odd.expandRow > :hover { background: #FFF !important; } #month_traffic { min-width: 85px; max-width: 95px;} #network { min-width: 115px; } #cpu, #ram, #hdd { min-width: 45px; max-width: 90px; } +#io { min-width: 55px; } #ping { max-width: 95px; } @media only screen and (max-width: 1080px) { diff --git a/web/js/serverstatus.js b/web/js/serverstatus.js index 21b1734..db7fb8e 100644 --- a/web/js/serverstatus.js +++ b/web/js/serverstatus.js @@ -20,16 +20,24 @@ function bytesToSize(bytes, precision, si) var ret; si = typeof si !== 'undefined' ? si : 0; if(si != 0) { - var megabyte = 1000 * 1000; + var kilobyte = 1000; + var megabyte = kilobyte * 1000; var gigabyte = megabyte * 1000; var terabyte = gigabyte * 1000; } else { - var megabyte = 1024 * 1024; + var kilobyte = 1024; + var megabyte = kilobyte * 1024; var gigabyte = megabyte * 1024; var terabyte = gigabyte * 1024; } - if ((bytes >= megabyte) && (bytes < gigabyte)) { + if ((bytes >= 0) && (bytes < kilobyte)) { + return bytes + ' B'; + + } else if ((bytes >= kilobyte) && (bytes < megabyte)) { + ret = (bytes / kilobyte).toFixed(precision) + ' K'; + + } else if ((bytes >= megabyte) && (bytes < gigabyte)) { ret = (bytes / megabyte).toFixed(precision) + ' M'; } else if ((bytes >= gigabyte) && (bytes < terabyte)) {