Commit ae409654 authored by Administrator's avatar Administrator

Update app.js

parent 506c79e2
......@@ -150,33 +150,34 @@ function postRequest() {
});
}
async function calculateSpeed() {
async function calculateSpeed() {
let d = await shellExec('vnstat -tr')
d = d.stdout
let d = await shellExec('vnstat -tr')
d = d.stdout
d = d.match(decimalPointRegex)
let arr = d.match(decimalPointRegex)
if (d.includes('kbit/s')) {
d[0] = 1
d[1] = 1
} else if (d.includes('Mbit/s')) {
} else if (d.includes('Gbit/s')) {
d[0] = d[0] * 1000
d[1] = d[1] * 1000
} else if (d.includes('bit/s')) {
d[0] = 1
d[1] = 1
}
if (d.includes('kbit/s')) {
arr[0] = 1
arr[1] = 1
} else if (d.includes('Mbit/s')) {
} else if (d.includes('Gbit/s')) {
arr[0] = arr[0] * 1000
arr[1] = arr[1] * 1000
} else if (d.includes('bit/s')) {
arr[0] = 1
arr[1] = 1
}
await sendRate(d[0], d[1])
await sendRate(arr[0], arr[1])
}
}
function sendRate(rx, tx) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment