mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-04 05:39:57 -05:00
Monitoring bandwidth for 2 seconds when running status main.
Updating archive's single-file call to use asyncio as well as fixing JSON error that used to be thrown. Trying two place for single-file executable. Adding more docs to bandwidth functions. Extracting reused functions out. Testing worker. Ordering bandwidth statuses by their name. Breaking down bandwidth by interface. Splitting download buttons to avoid overflow. Creating bandwidth worker which tracks server bandwidth usage to display on the status page. Testing get_bandwidth_info() with no psutil. Using psutil to fetch status. Adding bandwidth status.
This commit is contained in:
parent
d82b7c12fb
commit
c235ef65f3
11 changed files with 475 additions and 56 deletions
|
|
@ -355,8 +355,24 @@ export function humanFileSize(bytes, si = false, dp = 1) {
|
|||
return bytes.toFixed(dp) + ' ' + units[u];
|
||||
}
|
||||
|
||||
export function humanBandwidth(bytes) {
|
||||
// Convert bytes to Mbps and return a string.
|
||||
bytes /= 125;
|
||||
let size = 'Kbps';
|
||||
if (bytes > 1000) {
|
||||
bytes /= 125_000;
|
||||
size = 'Mbps';
|
||||
}
|
||||
if (bytes > 1000) {
|
||||
bytes /= 1000;
|
||||
size = 'Gbps';
|
||||
}
|
||||
bytes = Math.round(bytes);
|
||||
return `${bytes} ${size}`;
|
||||
}
|
||||
|
||||
export function humanNumber(num, dp = 1) {
|
||||
// Convert large numbers to a more human readable format.
|
||||
// Convert large numbers to a more human-readable format.
|
||||
// >> humanNumber(1000)
|
||||
// 1.0k
|
||||
// >> humanNumber(1500000)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue