Hi Guys
I'm looking at making some scripts that give me stats of my containers but I'm having difficulty getting CPU usage for it via the API.
When looking at a container's status via the API, I suspect the "cpu" value should represent the percentage of CPU its using against its allocation?
This container is at 20% usage (looking at its summary in the web UI), but the value is 0.
The same seems to apply to QEMU/KVM too - I'd loaded this VM at 100% but "cpu" still 0
Am I looking in the right place?
I'm looking at making some scripts that give me stats of my containers but I'm having difficulty getting CPU usage for it via the API.
When looking at a container's status via the API, I suspect the "cpu" value should represent the percentage of CPU its using against its allocation?
This container is at 20% usage (looking at its summary in the web UI), but the value is 0.
Code:
pve:/> get nodes/pmx01/lxc/100/status/current
200 OK
{
"cpu" : 0,
"cpus" : "1",
"disk" : 24936472576,
"diskread" : "911796413440",
"diskwrite" : "2439126016",
"ha" : {
"managed" : 0
},
"lock" : "",
"maxdisk" : 52710469632,
"maxmem" : 2147483648,
"maxswap" : 2147483648,
"mem" : 1572667392,
"name" : "syslog.example.com",
"netin" : 3827656894,
"netout" : 2730394259,
"pid" : "2980",
"status" : "running",
"swap" : 626429952,
"template" : "",
"type" : "lxc",
"uptime" : 257654
}
The same seems to apply to QEMU/KVM too - I'd loaded this VM at 100% but "cpu" still 0
Code:
pve:/> get nodes/pmx01/qemu/104/status/current
200 OK
{
"balloon" : 536870912,
"ballooninfo" : {
"actual" : 536870912,
"max_mem" : 536870912
},
"blockstat" : {
"ide2" : {
"account_failed" : false,
"account_invalid" : false,
"failed_flush_operations" : 0,
"failed_rd_operations" : 0,
"failed_wr_operations" : 0,
"flush_operations" : 0,
"flush_total_time_ns" : 0,
"idle_time_ns" : 2319738740,
"invalid_flush_operations" : 0,
"invalid_rd_operations" : 0,
"invalid_wr_operations" : 0,
"rd_bytes" : 14274774,
"rd_merged" : 0,
"rd_operations" : 793042,
"rd_total_time_ns" : 24046696658,
"timed_stats" : [],
"wr_bytes" : 0,
"wr_highest_offset" : 0,
"wr_merged" : 0,
"wr_operations" : 0,
"wr_total_time_ns" : 0
},
"virtio0" : {
"account_failed" : true,
"account_invalid" : true,
"failed_flush_operations" : 0,
"failed_rd_operations" : 0,
"failed_wr_operations" : 0,
"flush_operations" : 0,
"flush_total_time_ns" : 0,
"idle_time_ns" : 185813278619,
"invalid_flush_operations" : 0,
"invalid_rd_operations" : 0,
"invalid_wr_operations" : 0,
"rd_bytes" : 196230144,
"rd_merged" : 4,
"rd_operations" : 19872,
"rd_total_time_ns" : 65452421340,
"timed_stats" : [],
"wr_bytes" : 1512230912,
"wr_highest_offset" : 1860009472,
"wr_merged" : 436,
"wr_operations" : 76615,
"wr_total_time_ns" : 1770928176815
}
},
"cpu" : 0,
"cpus" : 1,
"disk" : 0,
"diskread" : 210504918,
"diskwrite" : 1512230912,
"ha" : {
"managed" : 0
},
"maxdisk" : 2147483648,
"maxmem" : 536870912,
"mem" : 266082277,
"name" : "vpn1.example.com",
"netin" : 2130369187,
"netout" : 1473923150,
"nics" : {
"tap104i0" : {
"netin" : "1148498060",
"netout" : "31456760"
},
"tap104i1" : {
"netin" : "981871127",
"netout" : "1442466390"
}
},
"pid" : "8787",
"qmpstatus" : "running",
"status" : "running",
"template" : "",
"uptime" : 2370124
}
Am I looking in the right place?