Fix turning stats to zero by casting them to int before multiplying.
This commit is contained in:
@@ -134,8 +134,8 @@ function LandingPage() {
|
|||||||
}
|
}
|
||||||
if (line2) {
|
if (line2) {
|
||||||
let values = line2.split(',')
|
let values = line2.split(',')
|
||||||
setUsageCPU(100 * parseInt(values[0]));
|
setUsageCPU(100 * parseFloat(values[0]));
|
||||||
setUsageMem(100 * parseInt(values[1]));
|
setUsageMem(100 * parseFloat(values[1]));
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.info('server stats unavailable')
|
console.info('server stats unavailable')
|
||||||
|
|||||||
+2
-2
@@ -39,5 +39,5 @@ if __name__ == "__main__":
|
|||||||
d_total = curr_total - prev_total
|
d_total = curr_total - prev_total
|
||||||
d_idle = curr_idle - prev_idle
|
d_idle = curr_idle - prev_idle
|
||||||
|
|
||||||
cpu_usage = ((d_total - d_idle)/d_total) * 100
|
cpu_usage = ((d_total - d_idle)/d_total)
|
||||||
print(round(cpu_usage, 20))
|
print(cpu_usage)
|
||||||
|
|||||||
+1
-1
@@ -7,6 +7,6 @@ cpu_usage=$L4G_DIR/lean4game/relay/cpu_usage.py
|
|||||||
# Execute python script
|
# Execute python script
|
||||||
cpu=$($python $cpu_usage)
|
cpu=$($python $cpu_usage)
|
||||||
# Calculate memory usage by computing used_memory/total_memory
|
# 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
|
printf "CPU, MEM\n%.2f, %.2f\n" $cpu $mem
|
||||||
|
|||||||
Reference in New Issue
Block a user