From: kushal waikar Subject: Strange CPU utilization values of Dom0 Date: Thu, 19 Feb 2009 22:00:44 +0530 (IST) Message-ID: <624185.89079.qm@web94201.mail.in2.yahoo.com> Reply-To: kushalwaikar@yahoo.co.in Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1094807269==" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --===============1094807269== Content-Type: multipart/alternative; boundary="0-920189639-1235061044=:89079" --0-920189639-1235061044=:89079 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Hi, =A0=A0=A0 I am trying to fetch CPU utilization of Dom0 using XenAPI & Pytho= n...I am not getting any error in my code...But Whatever CPU utilization I = am getting from my Dom0 is having value less than one... But actual CPU uti= lization seen under Virtual Machine Manager is in range of 1 to 100...It ne= ver exceeds 100 since it is percentage... If I multiply the values getting = here by 100 then sometimes my CPU utilization is exceeding above 100, which= is impossible practically (remember it is %age thts it should be <=3D100).= .. =A0My questions are--> 1. What kind of manipulation should be carried out on the vales obtained=A0= through=A0 my code to get the correct CPU utilization of Dom0....?=A0=20 2. Any other way to get correct values ? =A0 CODE AND ITS OUTPUT IS GIVEN BELOW-->=20 Test4.py--> " from xen.xm.XenAPI import Session=20 import time=20 session =3D None=20 #__________________________________________________________________________= _______ def print_cpu_utilization_Dom0():=20 =A0=A0=A0 cpus =3D session.xenapi.host_cpu.get_all()=20 =A0=A0=A0=A0=A0=A0 =A0=A0=A0 for i in range(1,100):=20 =A0=A0=A0=A0=A0=A0=A0=A0 =A0=A0=A0 for cpu in cpus:=20 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 load =3D session.xenapi.host_cpu.get_utilisat= ion(cpu)=20 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 print "HOST CPU USAGE :%s"% str(load)=20 =A0=A0=A0 =A0=A0=A0 time.sleep(1)=20 #__________________________________________________________________________= ______ ################### MAIN ######################=20 session=3DSession('httpu:///var/run/xend/xen-api.sock')=20 session.xenapi.login_with_password('','')=20 print_cpu_utilization_Dom0()=20 " Output--> [root@localhost ~]# python Test4.py=20 HOST CPU USAGE :0.316815906659=20 HOST CPU USAGE :0.316815906659=20 HOST CPU USAGE :0.344911681094=20 HOST CPU USAGE :0.344911681094=20 HOST CPU USAGE :0.133510673285=20 HOST CPU USAGE :0.133510673285=20 HOST CPU USAGE :0.148574903296=20 HOST CPU USAGE :0.148574903296=20 HOST CPU USAGE :0.224662819565=20 HOST CPU USAGE :0.224662819565=20 HOST CPU USAGE :0.266612999348=20 HOST CPU USAGE :0.266612999348=20 HOST CPU USAGE :0.231213527902=20 HOST CPU USAGE :0.231213527902=20 HOST CPU USAGE :0.188630822236=20 HOST CPU USAGE :0.188630822236=20 HOST CPU USAGE :0.193651973968=20 HOST CPU USAGE :0.193651973968=20 HOST CPU USAGE :0.263178127917=20 HOST CPU USAGE :0.263178127917=20 HOST CPU USAGE :0.302399599513=20 HOST CPU USAGE :0.302399599513=20 HOST CPU USAGE :0.497252504981=20 HOST CPU USAGE :0.497252504981=20 HOST CPU USAGE :0.163378468208=20 HOST CPU USAGE :0.163378468208=20 HOST CPU USAGE :0.124162530626=20 HOST CPU USAGE :0.124162530626=20 HOST CPU USAGE :0.123246183129=20 HOST CPU USAGE :0.123246183129=20 HOST CPU USAGE :0.135026907489=20 HOST CPU USAGE :0.135026907489=20 HOST CPU USAGE :0.123061438383=20 HOST CPU USAGE :0.123061438383=20 HOST CPU USAGE :0.12078425723=20 HOST CPU USAGE :0.12078425723=20 HOST CPU USAGE :0.121356409397=20 HOST CPU USAGE :0.121356409397=20 HOST CPU USAGE :0.141611269574=20 HOST CPU USAGE :0.141611269574=20 HOST CPU USAGE :0.122894492713=20 HOST CPU USAGE :0.122894492713=20 HOST CPU USAGE :0.123339760286=20 HOST CPU USAGE :0.123339760286=20 HOST CPU USAGE :0.140426165452=20 HOST CPU USAGE :0.140426165452=20 HOST CPU USAGE :0.197982342116=20 HOST CPU USAGE :0.197982342116=20 HOST CPU USAGE :0.143604339704=20 HOST CPU USAGE :0.143604339704=20 HOST CPU USAGE :0.121329276765=20 HOST CPU USAGE :0.121329276765=20 HOST CPU USAGE :0.122262038529=20 HOST CPU USAGE :0.122262038529=20 HOST CPU USAGE :0.142657108504=20 HOST CPU USAGE :0.142657108504=20 HOST CPU USAGE :0.144221052165=20 HOST CPU USAGE :0.144221052165=20 HOST CPU USAGE :0.133349764081=20 HOST CPU USAGE :0.133349764081=20 HOST CPU USAGE :0.13905321165=20 HOST CPU USAGE :0.13905321165=20 HOST CPU USAGE :0.132959577854=20 HOST CPU USAGE :0.132959577854=20 HOST CPU USAGE :0.133520591036=20 HOST CPU USAGE :0.133520591036=20 HOST CPU USAGE :0.121967122681=20 HOST CPU USAGE :0.121967122681=20 HOST CPU USAGE :0.115512335477=20 HOST CPU USAGE :0.115512335477=20 HOST CPU USAGE :0.121247277861=20 HOST CPU USAGE :0.121247277861=20 HOST CPU USAGE :0.121162922075=20 HOST CPU USAGE :0.121162922075=20 HOST CPU USAGE :0.199625023418=20 HOST CPU USAGE :0.199625023418=20 HOST CPU USAGE :0.602277504726=20 HOST CPU USAGE :0.602277504726=20 HOST CPU USAGE :0.339684598183=20 HOST CPU USAGE :0.339684598183=20 HOST CPU USAGE :0.113853948091=20 HOST CPU USAGE :0.113853948091=20 HOST CPU USAGE :0.201450235716=20 HOST CPU USAGE :0.201450235716=20 HOST CPU USAGE :0.15538562802=20 HOST CPU USAGE :0.15538562802=20 HOST CPU USAGE :0.121653406955=20 HOST CPU USAGE :0.121653406955=20 HOST CPU USAGE :0.123282728145=20 HOST CPU USAGE :0.123282728145=20 HOST CPU USAGE :0.128334557817=20 HOST CPU USAGE :0.128334557817=20 HOST CPU USAGE :0.13890167314=20 HOST CPU USAGE :0.13890167314=20 HOST CPU USAGE :0.14179786135=20 HOST CPU USAGE :0.14179786135=20 HOST CPU USAGE :0.182375532671=20 HOST CPU USAGE :0.182375532671=20 HOST CPU USAGE :0.232512245232=20 Thanks, Kushal Waikar kushalwaikar@yahoo.co.in =0A=0A=0A Add more friends to your messenger and enjoy! Go to http://m= essenger.yahoo.com/invite/ --0-920189639-1235061044=:89079 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable <= /tr>
Hi,
    I am trying to fetc= h CPU utilization of Dom0 using XenAPI & Python...I am not getting any = error in my code...But Whatever CPU utilization I am getting from my Dom0 i= s having value less than one... But actual CPU utilization seen under Virtu= al Machine Manager is in range of 1 to 100...It never exceeds 100 since it = is percentage... If I multiply the values getting here by 100 then sometime= s my CPU utilization is exceeding above 100, which is impossible practicall= y (remember it is %age thts it should be <=3D100)...

 My questions are-= ->

1. What kind of manipulation should be carried out on t= he vales obtained  through  my code to get the correct CPU utiliz= ation of Dom0....? 

2. Any other way to get correct values ?
 
CODE AND ITS OUTPUT IS GIVEN BELOW-->

Test4.py-->
"<= br>from xen.xm.XenAPI import Session
import time
session =3D None <= br>#_______________________________________________________________________= __________
def print_cpu_utilization_Dom0():
    cpus= =3D session.xenapi.host_cpu.get_all()
     &n= bsp;     for i in range(1,100):
    =          for cpu in cpus:
 &nbs= p;          load =3D session.xenapi.host= _cpu.get_utilisation(cpu)
         &= nbsp;  print "HOST CPU USAGE :%s"% str(load)
    &n= bsp;   time.sleep(1)
#_____________________________________________________________________= ___________
################### MAIN ######################
session= =3DSession('httpu:///var/run/xend/xen-api.sock')
session.xenapi.login_w= ith_password('','')
print_cpu_utilization_Dom0()
"

Output-->[root@localhost ~]# python Test4.py
HOST CPU USAGE :0.316815906659 HOST CPU USAGE :0.316815906659
HOST CPU USAGE :0.344911681094
HOS= T CPU USAGE :0.344911681094
HOST CPU USAGE :0.133510673285
HOST CPU= USAGE :0.133510673285
HOST CPU USAGE :0.148574903296
HOST CPU USAG= E :0.148574903296
HOST CPU USAGE :0.224662819565
HOST CPU USAGE :0.= 224662819565
HOST CPU USAGE :0.266612999348
HOST CPU USAGE :0.26661= 2999348
HOST CPU USAGE :0.231213527902
HOST CPU USAGE :0.2312135279= 02
HOST CPU USAGE :0.188630822236
HOST CPU USAGE :0.188630822236
HOST CPU USAGE :0.193651973968
HOST CPU USAGE :0.193651973968
= HOST CPU USAGE :0.263178127917
HOST CPU USAGE :0.263178127917
HOST = CPU USAGE :0.302399599513
HOST CPU USAGE :0.302399599513
HOST CPU U= SAGE :0.497252504981
HOST CPU USAGE :0.497252504981
HOST CPU USAGE = :0.163378468208
HOST CPU USAGE :0.163378468208
HOST CPU USAGE :0.12= 4162530626
HOST CPU USAGE :0.124162530626
HOST CPU USAGE :0.1232461= 83129
HOST CPU USAGE :0.123246183129
HOST CPU USAGE :0.135026907489=
HOST CPU USAGE :0.135026907489
HOST CPU USAGE :0.123061438383
= HOST CPU USAGE :0.123061438383
HOST CPU USAGE :0.12078425723
HOST C= PU USAGE :0.12078425723
HOST CPU USAGE :0.121356409397
HOST CPU USA= GE :0.121356409397
HOST CPU USAGE :0.141611269574
HOST CPU USAGE :0= .141611269574
HOST CPU USAGE :0.122894492713
HOST CPU USAGE :0.1228= 94492713
HOST CPU USAGE :0.123339760286
HOST CPU USAGE :0.123339760286
HOST CPU USAGE :0.140426165452
HOST CPU USAGE :0.1= 40426165452
HOST CPU USAGE :0.197982342116
HOST CPU USAGE :0.197982= 342116
HOST CPU USAGE :0.143604339704
HOST CPU USAGE :0.14360433970= 4
HOST CPU USAGE :0.121329276765
HOST CPU USAGE :0.121329276765 HOST CPU USAGE :0.122262038529
HOST CPU USAGE :0.122262038529
HOST= CPU USAGE :0.142657108504
HOST CPU USAGE :0.142657108504
HOST CPU = USAGE :0.144221052165
HOST CPU USAGE :0.144221052165
HOST CPU USAGE= :0.133349764081
HOST CPU USAGE :0.133349764081
HOST CPU USAGE :0.1= 3905321165
HOST CPU USAGE :0.13905321165
HOST CPU USAGE :0.13295957= 7854
HOST CPU USAGE :0.132959577854
HOST CPU USAGE :0.133520591036 =
HOST CPU USAGE :0.133520591036
HOST CPU USAGE :0.121967122681
H= OST CPU USAGE :0.121967122681
HOST CPU USAGE :0.115512335477
HOST C= PU USAGE :0.115512335477
HOST CPU USAGE :0.121247277861
HOST CPU USAGE :0.121247277861
HOST CPU USAGE :0.121162922075
HOST CPU = USAGE :0.121162922075
HOST CPU USAGE :0.199625023418
HOST CPU USAGE= :0.199625023418
HOST CPU USAGE :0.602277504726
HOST CPU USAGE :0.6= 02277504726
HOST CPU USAGE :0.339684598183
HOST CPU USAGE :0.339684= 598183
HOST CPU USAGE :0.113853948091
HOST CPU USAGE :0.11385394809= 1
HOST CPU USAGE :0.201450235716
HOST CPU USAGE :0.201450235716 HOST CPU USAGE :0.15538562802
HOST CPU USAGE :0.15538562802
HOST C= PU USAGE :0.121653406955
HOST CPU USAGE :0.121653406955
HOST CPU US= AGE :0.123282728145
HOST CPU USAGE :0.123282728145
HOST CPU USAGE := 0.128334557817
HOST CPU USAGE :0.128334557817
HOST CPU USAGE :0.138= 90167314
HOST CPU USAGE :0.13890167314
HOST CPU USAGE :0.1417978613= 5
HOST CPU USAGE :0.14179786135
HOST CPU USAGE :0.182375532671
= HOST CPU USAGE :0.182375532671
HOST CPU USAGE :0.232512245232


Thanks,
Kushal Waikar
kushalwaikar@yahoo.co.in

=0A=0A=0A=0A
Unlimited free= dom, unlimited storage. Get it= now --0-920189639-1235061044=:89079-- --===============1094807269== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --===============1094807269==--