Skip to content

Commit 15ac9a2

Browse files
committed
Adjust some logs
1 parent 8cfcdce commit 15ac9a2

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,7 +2311,7 @@ public PowerState getVmState(final Connect conn, final String vmName) {
23112311
final PowerState s = convertToPowerState(vms.getInfo().state);
23122312
return s;
23132313
} catch (final LibvirtException e) {
2314-
LOGGER.error(String.format("Can't get state for VM [%s] (retry=%s).", vmName, retry), e);
2314+
LOGGER.error("Could not get state for VM [{}] (retry={}) due to:", vmName, retry, e);
23152315
} finally {
23162316
try {
23172317
if (vms != null) {
@@ -4415,11 +4415,7 @@ public VmStatsEntry getVmStat(final Connect conn, final String vmName) throws Li
44154415
LibvirtExtendedVmStatsEntry oldStats = vmStats.get(vmName);
44164416

44174417
VmStatsEntry metrics = calculateVmMetrics(dm, oldStats, newStats);
4418-
4419-
String vmAsString = vmToString(dm);
4420-
LOGGER.info("Saving stats for VM [{}].", vmAsString);
44214418
vmStats.put(vmName, newStats);
4422-
LOGGER.debug("Saved stats for VM [{}]: [{}].", vmAsString, newStats);
44234419

44244420
return metrics;
44254421
} finally {
@@ -4454,7 +4450,7 @@ protected LibvirtExtendedVmStatsEntry getVmCurrentStats(final Domain dm) throws
44544450
* @throws LibvirtException
44554451
*/
44564452
protected void getVmCurrentCpuStats(final Domain dm, final LibvirtExtendedVmStatsEntry stats) throws LibvirtException {
4457-
LOGGER.debug("Getting CPU stats for VM [{}].", vmToString(dm));
4453+
LOGGER.trace("Getting CPU stats for VM [{}].", vmToString(dm));
44584454
stats.setCpuTime(dm.getInfo().cpuTime);
44594455
}
44604456

@@ -4466,7 +4462,7 @@ protected void getVmCurrentCpuStats(final Domain dm, final LibvirtExtendedVmStat
44664462
*/
44674463
protected void getVmCurrentNetworkStats(final Domain dm, final LibvirtExtendedVmStatsEntry stats) throws LibvirtException {
44684464
final String vmAsString = vmToString(dm);
4469-
LOGGER.debug("Getting network stats for VM [{}].", vmAsString);
4465+
LOGGER.trace("Getting network stats for VM [{}].", vmAsString);
44704466
final List<InterfaceDef> vifs = getInterfaces(dm.getConnect(), dm.getName());
44714467
LOGGER.debug("Found [{}] network interface(s) for VM [{}].", vifs.size(), vmAsString);
44724468
double rx = 0;
@@ -4488,7 +4484,7 @@ protected void getVmCurrentNetworkStats(final Domain dm, final LibvirtExtendedVm
44884484
*/
44894485
protected void getVmCurrentDiskStats(final Domain dm, final LibvirtExtendedVmStatsEntry stats) throws LibvirtException {
44904486
final String vmAsString = vmToString(dm);
4491-
LOGGER.debug("Getting disk stats for VM [{}].", vmAsString);
4487+
LOGGER.trace("Getting disk stats for VM [{}].", vmAsString);
44924488
final List<DiskDef> disks = getDisks(dm.getConnect(), dm.getName());
44934489
LOGGER.debug("Found [{}] disk(s) for VM [{}].", disks.size(), vmAsString);
44944490
long io_rd = 0;
@@ -4526,25 +4522,25 @@ protected VmStatsEntry calculateVmMetrics(final Domain dm, final LibvirtExtended
45264522
final String vmAsString = vmToString(dm);
45274523

45284524
metrics.setEntityType("vm");
4529-
LOGGER.debug("Writing VM [{}]'s CPU and memory information into the metrics.", vmAsString);
4525+
LOGGER.trace("Writing VM [{}]'s CPU and memory information into the metrics.", vmAsString);
45304526
metrics.setNumCPUs(info.nrVirtCpu);
45314527
metrics.setMemoryKBs(info.maxMem);
45324528
metrics.setTargetMemoryKBs(info.memory);
4533-
LOGGER.debug("Trying to get free memory for VM [{}].", vmAsString);
4529+
LOGGER.trace("Trying to get free memory for VM [{}].", vmAsString);
45344530
metrics.setIntFreeMemoryKBs(getMemoryFreeInKBs(dm));
45354531

45364532
if (oldStats != null) {
45374533
LOGGER.debug("Old stats exist for VM [{}]; therefore, the utilization will be calculated.", vmAsString);
45384534

4539-
LOGGER.debug("Calculating CPU utilization for VM [{}].", vmAsString);
4535+
LOGGER.trace("Calculating CPU utilization for VM [{}].", vmAsString);
45404536
final Calendar now = Calendar.getInstance();
45414537
long elapsedTime = now.getTimeInMillis() - oldStats.getTimestamp().getTimeInMillis();
45424538
double utilization = (info.cpuTime - oldStats.getCpuTime()) / ((double) elapsedTime * 1000000 * info.nrVirtCpu);
45434539
if (utilization > 0) {
45444540
metrics.setCPUUtilization(utilization * 100);
45454541
}
45464542

4547-
LOGGER.debug("Calculating network utilization for VM [{}].", vmAsString);
4543+
LOGGER.trace("Calculating network utilization for VM [{}].", vmAsString);
45484544
final double deltarx = newStats.getNetworkReadKBs() - oldStats.getNetworkReadKBs();
45494545
if (deltarx > 0) {
45504546
metrics.setNetworkReadKBs(deltarx);
@@ -4554,7 +4550,7 @@ protected VmStatsEntry calculateVmMetrics(final Domain dm, final LibvirtExtended
45544550
metrics.setNetworkWriteKBs(deltatx);
45554551
}
45564552

4557-
LOGGER.debug("Calculating disk utilization for VM [{}].", vmAsString);
4553+
LOGGER.trace("Calculating disk utilization for VM [{}].", vmAsString);
45584554
final double deltaiord = newStats.getDiskReadIOs() - oldStats.getDiskReadIOs();
45594555
if (deltaiord > 0) {
45604556
metrics.setDiskReadIOs(deltaiord);

0 commit comments

Comments
 (0)