changqian zuo
2015-Jul-24 11:34 UTC
Re: [libvirt-users] virsh dominfo does not show correct cpuTime
I was getting vCPU use time outside of guest with libvirt-python API, and them calculate utilization with (cpuTime2 - cpuTime1) / (t2 - t1). I was not doing this inside the guest os. 2015-07-24 15:09 GMT+08:00 2020human <human2020@qq.com>:> You calculate is vCPU use time not utilization。 > > use_time/total_cpu_time is utilization。 > > total_cpu_time=`cat /proc/stat |sed -n '1p'|awk '{ print > sum=$2+$3+$4+$5+$6+$7+$8+$9+$10}'` > > > ------------------ 原始邮件 ------------------ > *发件人:* "changqian zuo";<zuochangqian@gmail.com>; > *发送时间:* 2015年7月24日(星期五) 中午1:51 > *收件人:* "libvirt-users"<libvirt-users@redhat.com>; > *主题:* [libvirt-users] virsh dominfo does not show correct cpuTime > > Hi, > > I am doing some domain resource monitoring work. I use > > cat /dev/urandom | md5sum > > to simulate vCPU load and write a script to calculate vCPU utilization. It > seems all good at the beginning. After I abort the ``cat ... md5sum`` > command in domain, I see some strange data as below: > > CPU time: 8410960000000 > CPU util: 99.8410609331% > CPU time: 8411970000000 > CPU util: 100.843672381% > CPU time: 8412380000000 > CPU util: 40.9336949531% > CPU time: 8412440000000 > CPU util: 5.9899303915% > *CPU time: 8412440000000* > *CPU util: 0.0%* > CPU time: 8412490000000 > CPU util: 4.99165856007% > *CPU time: 8412490000000* > *CPU util: 0.0%* > *CPU time: 8412490000000* > *CPU util: 0.0%* > CPU time: 8412570000000 > CPU util: 7.987195515% > *CPU time: 8412570000000* > *CPU util: 0.0%* > CPU time: 8412590000000 > CPU util: 1.99668576091% > CPU time: 8412670000000 > CPU util: 7.98700539474% > CPU time: 8412720000000 > CPU util: 4.99167281754% > CPU time: 8412780000000 > CPU util: 5.98888552548% > > Looking at those 0.0% lines. Strange, though the guest is running, cpuTime > does not increase. How can this happen? Any one helps? Thanks. > > Host information: > > - CentOS Linux release 7.0.1406 (Core) > - libvirt 1.2.8 > - qemu-kvm-rhev 2.1.2 > > ----- python script to capture cpu domain usage ---- > import libvirt > import time > > conn = libvirt.openReadOnly("qemu:///system") > dom = conn.lookupByName('cpu-test') > last_time = time.time() > last_cpu_time = dom.info()[4] > > while True: > time.sleep(1) > this_time = time.time() > dom_info = dom.info() > > print "CPU time: %s" % dom_info[4] > print "CPU util: %s%%" % ((dom_info[4] - last_cpu_time) / ((this_time - > last_time) * 10000000)) > > last_cpu_time = dom_info[4] > last_time = this_time > ----------------------------- end ----------------------------- > > >
Seemingly Similar Threads
- virsh dominfo does not show correct cpuTime
- [PATCH] Add vncviewer xm compatibility options the 'xl create' command
- Bug#444000: [ijc@hellion.org.uk: move core dumps to /var/lib/xen/dump]
- Bug#706233: move core dumps to /var/lib/xen/dump
- [PATCH] tools: xl: on create, if debug && !daemonize, wait for domain destroy in the foreground