From 0b76c26ce971cb1196c520d76ea4c785c6cd915c Mon Sep 17 00:00:00 2001 From: kishan Date: Thu, 2 Dec 2010 14:11:02 +0530 Subject: [PATCH] bug 7216: show capacity alerts at pod level instead of zone status 7216: resolved fixed --- .../src/com/cloud/alert/AlertManagerImpl.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/server/src/com/cloud/alert/AlertManagerImpl.java b/server/src/com/cloud/alert/AlertManagerImpl.java index 71767e63c32..c15c9f457c2 100644 --- a/server/src/com/cloud/alert/AlertManagerImpl.java +++ b/server/src/com/cloud/alert/AlertManagerImpl.java @@ -382,9 +382,16 @@ public class AlertManagerImpl implements AlertManager { Map> capacityDcTypeMap = new HashMap>(); for (CapacityVO capacity : capacityList) { - long dataCenterId = capacity.getDataCenterId(); + long dataCenterId = capacity.getDataCenterId(); + long podId = capacity.getPodId(); short type = capacity.getCapacityType(); - String key = "dc" + dataCenterId + "t" + type; + String key = null; + if((type == CapacityVO.CAPACITY_TYPE_PUBLIC_IP) || (type == CapacityVO.CAPACITY_TYPE_SECONDARY_STORAGE)){ + key = "dc" + dataCenterId + "t" + type; + } else { + key = "pod" + podId + "t" + type; + } + List list = capacityDcTypeMap.get(key); if (list == null) { list = new ArrayList(); @@ -399,7 +406,8 @@ public class AlertManagerImpl implements AlertManager { double usedCapacity = 0d; CapacityVO cap = capacities.get(0); short capacityType = cap.getCapacityType(); - long dataCenterId = cap.getDataCenterId(); + long dataCenterId = cap.getDataCenterId(); + long podId = cap.getPodId(); for (CapacityVO capacity : capacities) { totalCapacity += capacity.getTotalCapacity(); @@ -409,7 +417,9 @@ public class AlertManagerImpl implements AlertManager { double capacityPct = (usedCapacity / totalCapacity); double thresholdLimit = 1.0; DataCenterVO dcVO = _dcDao.findById(dataCenterId); - String dcName = ((dcVO == null) ? "unknown" : dcVO.getName()); + String dcName = ((dcVO == null) ? "unknown" : dcVO.getName()); + HostPodVO pod = _podDao.findById(podId); + String podName = ((pod == null) ? "unknown" : pod.getName()); String msgSubject = ""; String msgContent = ""; String totalStr = ""; @@ -420,28 +430,28 @@ public class AlertManagerImpl implements AlertManager { switch (capacityType) { case CapacityVO.CAPACITY_TYPE_MEMORY: thresholdLimit = _memoryCapacityThreshold; - msgSubject = "System Alert: Low Available Memory in availablity zone " + dcName; + msgSubject = "System Alert: Low Available Memory in pod "+podName+" of availablity zone " + dcName; totalStr = formatBytesToMegabytes(totalCapacity); usedStr = formatBytesToMegabytes(usedCapacity); msgContent = "System memory is low, total: " + totalStr + " MB, used: " + usedStr + " MB (" + pctStr + "%)"; break; case CapacityVO.CAPACITY_TYPE_CPU: thresholdLimit = _cpuCapacityThreshold; - msgSubject = "System Alert: Low Unallocated CPU in availablity zone " + dcName; + msgSubject = "System Alert: Low Unallocated CPU in pod "+podName+" of availablity zone " + dcName; totalStr = _dfWhole.format(totalCapacity); usedStr = _dfWhole.format(usedCapacity); msgContent = "Unallocated CPU is low, total: " + totalStr + " Mhz, used: " + usedStr + " Mhz (" + pctStr + "%)"; break; case CapacityVO.CAPACITY_TYPE_STORAGE: thresholdLimit = _storageCapacityThreshold; - msgSubject = "System Alert: Low Available Storage in availablity zone " + dcName; + msgSubject = "System Alert: Low Available Storage in pod "+podName+" of availablity zone " + dcName; totalStr = formatBytesToMegabytes(totalCapacity); usedStr = formatBytesToMegabytes(usedCapacity); msgContent = "Available storage space is low, total: " + totalStr + " MB, used: " + usedStr + " MB (" + pctStr + "%)"; break; case CapacityVO.CAPACITY_TYPE_STORAGE_ALLOCATED: thresholdLimit = _storageAllocCapacityThreshold; - msgSubject = "System Alert: Remaining unallocated Storage is low in availablity zone " + dcName; + msgSubject = "System Alert: Remaining unallocated Storage is low in pod "+podName+" of availablity zone " + dcName; totalStr = formatBytesToMegabytes(totalCapacity); usedStr = formatBytesToMegabytes(usedCapacity); msgContent = "Unallocated storage space is low, total: " + totalStr + " MB, allocated: " + usedStr + " MB (" + pctStr + "%)"; @@ -455,7 +465,7 @@ public class AlertManagerImpl implements AlertManager { break; case CapacityVO.CAPACITY_TYPE_PRIVATE_IP: thresholdLimit = _privateIPCapacityThreshold; - msgSubject = "System Alert: Number of unallocated private IPs is low in availablity zone " + dcName; + msgSubject = "System Alert: Number of unallocated private IPs is low in pod "+podName+" of availablity zone " + dcName; totalStr = Double.toString(totalCapacity); usedStr = Double.toString(usedCapacity); msgContent = "Number of unallocated private IPs is low, total: " + totalStr + ", allocated: " + usedStr + " (" + pctStr + "%)";