I’m trying to get programatically something similar to kubectl top node. I can get each node cpu/memory usage info and I also want to print the %, but I don’t know where can I find information about the total to compare against.
Example:
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
master-6zjs4 708m 14% 4677Mi 64%
master-rjvg6 942m 18% 5177Mi 71%
master-w6hpc 1415m 28% 5745Mi 78%
worker-277g5 970m 3% 12441Mi 5%
worker-4hf4x 902m 3% 16310Mi 6%
worker-5jcz7 802m 3% 10173Mi 4%
worker-5s74n 774m 3% 9075Mi 3%
worker-6dckk 699m 2% 7392Mi 3%
worker-kv9lh 713m 2% 11621Mi 4%
worker-whk6x 991m 3% 10775Mi 4%
For the last node in the list I get this usage info:
"usage": {
"cpu": "990697725n",
"memory": "11033864Ki"
}
My question is: which field/attribute/property stores the total limit of CPU in order to calculate that 3% that is shown in the command output?
Thanks.
I think the API library is not important. In any case I’m using Java fabric8 kubernetes-client.