Calculation using Javascript - Math

223
March 13, 2018, at 5:21 PM

JSON Statistics

cpu_usage:
percpu_usage:Array(4)
0:14808372153
1:518274597399
2:42110957200
3:133104944364
length:4
__proto__:Array(0)
total_usage:708298871116
usage_in_kernelmode:15350000000
usage_in_usermode:692790000000
__proto__:Object
online_cpus:4
system_cpu_usage:16883147380000000

I get a json like this that gives the cpu_usage

I made docker top and it's around 99-100% usage but my calculation give less than 1%. Something like 0,004

What am I doing wrong?

success: function (statistics) {
    var totalUsage = statistics.cpu_stats.system_cpu_usage;
    var currentUsage =  statistics.cpu_stats.cpu_usage.total_usage;
    var cpuUsage = (currentUsage / totalUsage) * 100;
 }

The formula you need is this, but I don't have precpu_stats so I need to save the previous data somehow:

(cpu_stats.cpu_usage.total_usage - precpu_stats.cpu_usage.total_usage) / (cpu_stats.system_cpu_usage - precpu_stats.system_cpu_usage)
Rent Charter Buses Company
READ ALSO
Add row only once when found with multiple duplicate values javascript

Add row only once when found with multiple duplicate values javascript

How to add row only once when found with multiple duplicate valuesHere it adds rows according to the number of accountNumber == accountNumberInTable found

170
Image map hover code not working

Image map hover code not working

I have the following image mapping code:

239
Span on click move to a div

Span on click move to a div

I am trying to make make it possible that when someon click on move to then the page moves slowy to up where there is container division how ever it doesnt work

201
Getting items with info from data-attributes not filling cart with jQuery

Getting items with info from data-attributes not filling cart with jQuery

This is my first try creating the functionalities of a shopping cart so i'm still getting the grasps on this

193