Francesco Romani has uploaded a new change for review. Change subject: WIP: sampling: make _getCpuCoresStats a function ......................................................................
WIP: sampling: make _getCpuCoresStats a function Change-Id: If602a84096db7aa7d1a6672b84d62287e08b0ac2 Signed-off-by: Francesco Romani <from...@redhat.com> --- M vdsm/virt/sampling.py 1 file changed, 31 insertions(+), 31 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/29/40429/1 diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py index cbe53ef..f61514b 100644 --- a/vdsm/virt/sampling.py +++ b/vdsm/virt/sampling.py @@ -649,40 +649,10 @@ stats['bootTime'] = self._boot_time() stats['numaNodeMemFree'] = hs1.numaNodeMem.nodesMemSample - stats['cpuStatistics'] = self._getCpuCoresStats() + stats['cpuStatistics'] = _get_cpu_core_stats(hs0, hs1) stats['v2vJobs'] = v2v.get_jobs_status() return stats - - def _getCpuCoresStats(self): - """ - :returns: a dict that with the following formats: - - {'<cpuId>': {'numaNodeIndex': int, 'cpuSys': 'str', - 'cpuIdle': 'str', 'cpuUser': 'str'}, ...} - """ - cpuCoreStats = {} - for nodeIndex, numaNode in caps.getNumaTopology().iteritems(): - cpuCores = numaNode['cpus'] - for cpuCore in cpuCores: - coreStat = {} - coreStat['nodeIndex'] = int(nodeIndex) - hs0, hs1 = self._samples[0], self._samples[-1] - interval = hs1.timestamp - hs0.timestamp - jiffies = (hs1.cpuCores.getCoreSample(cpuCore)['user'] - - hs0.cpuCores.getCoreSample(cpuCore)['user']) % \ - (2 ** 32) - coreStat['cpuUser'] = ("%.2f" % (jiffies / interval)) - jiffies = (hs1.cpuCores.getCoreSample(cpuCore)['sys'] - - hs0.cpuCores.getCoreSample(cpuCore)['sys']) % \ - (2 ** 32) - coreStat['cpuSys'] = ("%.2f" % (jiffies / interval)) - coreStat['cpuIdle'] = ("%.2f" % - max(0.0, 100.0 - - float(coreStat['cpuUser']) - - float(coreStat['cpuSys']))) - cpuCoreStats[str(cpuCore)] = coreStat - return cpuCoreStats def _getInterfacesStats(self): """ @@ -754,6 +724,36 @@ return stats +def _get_cpu_core_stats(hs0, hs1): + """ + :returns: a dict that with the following formats: + + {'<cpuId>': {'numaNodeIndex': int, 'cpuSys': 'str', + 'cpuIdle': 'str', 'cpuUser': 'str'}, ...} + """ + cpuCoreStats = {} + for nodeIndex, numaNode in caps.getNumaTopology().iteritems(): + cpuCores = numaNode['cpus'] + for cpuCore in cpuCores: + coreStat = {} + coreStat['nodeIndex'] = int(nodeIndex) + interval = hs1.timestamp - hs0.timestamp + jiffies = (hs1.cpuCores.getCoreSample(cpuCore)['user'] - + hs0.cpuCores.getCoreSample(cpuCore)['user']) % \ + (2 ** 32) + coreStat['cpuUser'] = ("%.2f" % (jiffies / interval)) + jiffies = (hs1.cpuCores.getCoreSample(cpuCore)['sys'] - + hs0.cpuCores.getCoreSample(cpuCore)['sys']) % \ + (2 ** 32) + coreStat['cpuSys'] = ("%.2f" % (jiffies / interval)) + coreStat['cpuIdle'] = ("%.2f" % + max(0.0, 100.0 - + float(coreStat['cpuUser']) - + float(coreStat['cpuSys']))) + cpuCoreStats[str(cpuCore)] = coreStat + return cpuCoreStats + + def _getLinkSpeed(dev): if dev.isNIC(): speed = netinfo.nicSpeed(dev.name) -- To view, visit https://gerrit.ovirt.org/40429 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If602a84096db7aa7d1a6672b84d62287e08b0ac2 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Francesco Romani <from...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches