mirror of https://gitee.com/openkylin/libvirt.git
virsh: host: refactor cmdNodeCpuStats()
Signed-off-by: Kristina Hanicova <khanicov@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
21a0019392
commit
096da894cd
|
@ -803,30 +803,30 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd)
|
||||||
cpu_stats[i]);
|
cpu_stats[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (present[VIRSH_CPU_USAGE]) {
|
||||||
|
vshPrint(ctl, "%-15s %5.1llu%%\n",
|
||||||
|
_("usage:"), cpu_stats[VIRSH_CPU_USAGE]);
|
||||||
|
vshPrint(ctl, "%-15s %5.1llu%%\n",
|
||||||
|
_("idle:"), 100 - cpu_stats[VIRSH_CPU_USAGE]);
|
||||||
} else {
|
} else {
|
||||||
if (present[VIRSH_CPU_USAGE]) {
|
double usage, total_time = 0;
|
||||||
vshPrint(ctl, "%-15s %5.1llu%%\n",
|
for (i = 0; i < VIRSH_CPU_USAGE; i++)
|
||||||
_("usage:"), cpu_stats[VIRSH_CPU_USAGE]);
|
total_time += cpu_stats[i];
|
||||||
vshPrint(ctl, "%-15s %5.1llu%%\n",
|
|
||||||
_("idle:"), 100 - cpu_stats[VIRSH_CPU_USAGE]);
|
|
||||||
} else {
|
|
||||||
double usage, total_time = 0;
|
|
||||||
for (i = 0; i < VIRSH_CPU_USAGE; i++)
|
|
||||||
total_time += cpu_stats[i];
|
|
||||||
|
|
||||||
usage = (cpu_stats[VIRSH_CPU_USER] + cpu_stats[VIRSH_CPU_SYSTEM])
|
usage = (cpu_stats[VIRSH_CPU_USER] + cpu_stats[VIRSH_CPU_SYSTEM])
|
||||||
/ total_time * 100;
|
/ total_time * 100;
|
||||||
|
|
||||||
vshPrint(ctl, "%-15s %5.1lf%%\n", _("usage:"), usage);
|
vshPrint(ctl, "%-15s %5.1lf%%\n", _("usage:"), usage);
|
||||||
for (i = 0; i < VIRSH_CPU_USAGE; i++) {
|
for (i = 0; i < VIRSH_CPU_USAGE; i++) {
|
||||||
if (present[i]) {
|
if (present[i]) {
|
||||||
vshPrint(ctl, "%-15s %5.1lf%%\n", _(virshCPUOutput[i]),
|
vshPrint(ctl, "%-15s %5.1lf%%\n", _(virshCPUOutput[i]),
|
||||||
cpu_stats[i] / total_time * 100);
|
cpu_stats[i] / total_time * 100);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue