<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><span style="font-size: 14px;">Hi, all.  </span><div><span style="font-size: 14px;">While monitoring KVM VMs’ disk utilisation using libvirt API “virDomainBlockStats", </span><span style="font-size: 14px;">I find that the results acquired is not consistent </span></div><div><span style="font-size: 14px;">with the value read from /proc/[vm_pid]/io(i only </span><span style="font-size: 14px;">care about “rd_bytes" and “wr_bytes” fields). Since libvirt doesn’t support host level monitoring,  </span></div><div><span style="font-size: 14px;">i have to calculate the host’s disk utilisation by reading from the <font color="#831100">/proc/diskstats</font> file. What’s worse, the individual VM’s disk data may </span></div><div><span style="font-size: 14px;">be greater that the physical disk’s total value during some sampling time. </span></div><div><span style="font-size: 14px;"><br></span></div><div><span style="font-size: 14px;">It is supposed that the VM’s disk “rd_bytes" and “wr_bytes" should never exceed the value of the physical disk respectively, right ? Doesn’t</span></div><div><span style="font-size: 14px;">libvirt virDomainBlockStats read disk information from “proc” ?  </span></div><div><span style="font-size: 14px;"><br></span></div><div><span style="font-size: 14px;">I want to calculate VM’s bandwidth, here is my way:</span></div><div><span class="Apple-tab-span" style="font-size: 14px; white-space: pre;">      </span><span style="font-size: 14px;">Firstly, we can get total disk utilisation using tools like iostat("iostat -x”, the %util field represent the disk’s utilisation percentage)</span></div><div><span style="font-size: 14px;"><span class="Apple-tab-span" style="white-space:pre">       </span>Then, given a sampling time period, 10s for example, i collected total bytes read/written by each VM by virDomainBlockStats and total</span></div><div><span class="Apple-tab-span" style="font-size: 14px; white-space: pre;">                </span><span style="font-size: 14px;">bytes of the physical disk by /proc/diskstats, then delta(VM’s rd+wr bytes)/delta(physical disk’s rd+wr bytes) * %util is the VM’s </span></div><div><span style="font-size: 14px;"><span class="Apple-tab-span" style="white-space:pre">          </span>disk utilization percentage during this time period.</span></div><div><span style="font-size: 14px;">Since the appearance of the above situation, i can’t get correct result. I have search a lot for this question, but no answers.  Any help would</span></div><div><span style="font-size: 14px;">be appreciated. </span></div><div><span style="font-size: 14px;"><br></span></div><div><br></div></body></html>