<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Hi All,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I would like to know if there is a way to fetch the “CPU Usage and Memory Usage for VM “  and CPU Usage and Memory Usage for a Host in the KVM environment using libvirt java sdk .<o:p></o:p></p>
<p class="MsoNormal">I am using libvirt-0.5.1.jar.<o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D">This is the maximum Information I could fetch using the libvirt java API.:<o:p></o:p></span></p>
<div class="MsoNormal" align="center" style="text-align:center"><span style="color:#1F497D">
<hr size="2" width="100%" align="center">
</span></div>
<p class="MsoNormal"><span style="font-family:"Courier New";color:#4F81BD">vmname:flow-cluster1<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New";color:#4F81BD">state:VIR_DOMAIN_RUNNING<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New";color:#4F81BD">ostype:hvm<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New";color:#4F81BD">guest id :8f0b96e5-1e08-40ce-aea1-9985d80fcabb<o:p></o:p></span></p>
<p class="MsoNormal"><b><span style="font-family:"Courier New";color:#1F497D">Max memory : 8388608<o:p></o:p></span></b></p>
<p class="MsoNormal"><b><span style="font-family:"Courier New";color:#1F497D">Max cpus : 4<o:p></o:p></span></b></p>
<p class="MsoNormal"><b><span style="font-family:"Courier New";color:#1F497D">Guest Info-cputime: 58930890000000<o:p></o:p></span></b></p>
<p class="MsoNormal"><b><span style="font-family:"Courier New";color:#1F497D">Guest Info-maxMem: 8388608<o:p></o:p></span></b></p>
<p class="MsoNormal"><b><span style="font-family:"Courier New";color:#1F497D">Guest Info-memory: 8388608<o:p></o:p></span></b></p>
<p class="MsoNormal"><b><span style="font-family:"Courier New";color:#1F497D">Guest Info-nrVirtCpu: 4<o:p></o:p></span></b></p>
<p class="MsoNormal"><span style="font-family:"Courier New";color:#4F81BD">MemoryStatistic: 8388608<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New";color:#4F81BD">Autostart :false<o:p></o:p></span></p>
<div class="MsoNormal" align="center" style="text-align:center"><span style="color:#1F497D">
<hr size="2" width="100%" align="center">
</span></div>
<p class="MsoNormal">I tried looking into the libvirt java sdk but did not find any methods to fetch the exact  CPU Usage percentage and Memory Usage percentage for a VM and Host.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Can you please provide me with the java example if possible.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal">Prashanth R<o:p></o:p></p>
</div>
</body>
</html>