nparams in virNodeGetCPUStats and CPU utilization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
I am trying to get the CPU utilization of a node and I am using virNodeGetCPUStats(...)

Here is my code snippet. The error checking is omitted for brevity.

/* get the number of params */
retval = virNodeGetCPUStats (conn, VIR_NODE_CPU_STATS_ALL_CPUS,\
                   NULL, &nparams, 0);

printf ("nparams: %d\n", nparams);

/* allocate space for the params */
params = (virNodeCPUStatsPtr *) malloc (sizeof (virNodeCPUStats) * nparams );

/* get the values */
retval = virNodeGetCPUStats (conn, VIR_NODE_CPU_STATS_ALL_CPUS,\
                params, &nparams, 0);

for ( i = 0 ; i < nparams ; i++)
{
    printf ("params[%d].field: %s \tparams[%d].value: %llu\n",
        i, params[i].field, i, params[i].value);
}

output:

nparams: 4
params[0].field: kernel     params[0].value: 77930000000
params[1].field: user       params[1].value: 568270000000
params[2].field: idle       params[2].value: 471429230000000
params[3].field: iowait     params[3].value: 67100000000


The documentation at http://libvirt.org/html/libvirt-libvirt.html on the
virNodeGetCPUStats(...) API says that nparams is dynamic. Does that mean that not all params are available for a node? I was hoping that nparams would be 5 and that params[4]
would contain the utilization (VIR_NODE_CPU_STATS_UTILIZATION).

If the answer to the above is 'yes'. Then, I was wondering as to what would be the
correct way to calculate the CPU utilization of a node?.

Thanks,
--Hari

_______________________________________________
libvirt-users mailing list
libvirt-users@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvirt-users




[Index of Archives]     [Virt Tools]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux