Fix turning stats to zero by casting them to int before multiplying.

pull/279/head
matlorr 1 year ago
parent 5f30572741
commit 52898d93e7

@ -134,8 +134,8 @@ function LandingPage() {
}
if (line2) {
let values = line2.split(',')
setUsageCPU(100 * parseInt(values[0]));
setUsageMem(100 * parseInt(values[1]));
setUsageCPU(100 * parseFloat(values[0]));
setUsageMem(100 * parseFloat(values[1]));
}
}).catch(err => {
console.info('server stats unavailable')

@ -39,5 +39,5 @@ if __name__ == "__main__":
d_total = curr_total - prev_total
d_idle = curr_idle - prev_idle
cpu_usage = ((d_total - d_idle)/d_total) * 100
print(round(cpu_usage, 20))
cpu_usage = ((d_total - d_idle)/d_total)
print(cpu_usage)

@ -7,6 +7,6 @@ cpu_usage=$L4G_DIR/lean4game/relay/cpu_usage.py
# Execute python script
cpu=$($python $cpu_usage)
# Calculate memory usage by computing used_memory/total_memory
mem=$(free | sed '2q;d' | awk '{print $3/$2*100}')
mem=$(free | sed '2q;d' | awk '{print $3/$2}')
printf "CPU, MEM\n%.2f, %.2f\n" $cpu $mem

Loading…
Cancel
Save