ofri masad has uploaded a new change for review.

Change subject: core: Add 5 new Events to AuditLog
......................................................................

core: Add 5 new Events to AuditLog

Added 5 new events to AuditLog:
 - Host memory use over threshold
 - Host cpu use over threshold
 - Host network use over threshold
 - Host free swap memory under threshold
 - Host swap memory use over threshold

Change-Id: Id382c4688bdcf46f7b343ff0661893a97b5dc726
Signed-off-by: Ofri Masad <[email protected]>
---
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
M 
backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
5 files changed, 113 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/65/10865/1

diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
index 2c92003..2cb91dd 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
@@ -24,6 +24,11 @@
     VDS_MANUAL_FENCE_STATUS_FAILED(495),
     VDS_MANUAL_FENCE_FAILED_CALL_FENCE_SPM(530),
     VDS_LOW_MEM(531, AuditLogTimeInterval.HOUR.getValue() * 5),
+    VDS_HIGH_MEM_USE(532, AuditLogTimeInterval.MINUTE.getValue() * 30),
+    VDS_HIGH_NETWORK_USE(533, AuditLogTimeInterval.MINUTE.getValue() * 30),
+    VDS_HIGH_CPU_USE(534, AuditLogTimeInterval.MINUTE.getValue() * 30),
+    VDS_HIGH_SWAP_USE(535, AuditLogTimeInterval.MINUTE.getValue() * 30),
+    VDS_LOW_SWAP(536, AuditLogTimeInterval.MINUTE.getValue() * 30),
     VDS_FENCE_STATUS(496),
     VDS_FENCE_STATUS_FAILED(497),
     VDS_APPROVE(498),
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
index 942ec43..501eefa 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
@@ -1331,6 +1331,31 @@
     @DefaultValueAttribute("false")
     HardwareInfoEnabled(410),
 
+    @Reloadable
+    @TypeConverterAttribute(Integer.class)
+    @DefaultValueAttribute("95")
+    LogMaxPhysicalMemoryUsedThresholdInPercentage(411),
+
+    @Reloadable
+    @TypeConverterAttribute(Integer.class)
+    @DefaultValueAttribute("95")
+    LogMaxCpuUsedThresholdInPercentage(412),
+
+    @Reloadable
+    @TypeConverterAttribute(Integer.class)
+    @DefaultValueAttribute("95")
+    LogMaxNetworkUsedThresholdInPercentage(413),
+
+    @Reloadable
+    @TypeConverterAttribute(Integer.class)
+    @DefaultValueAttribute("256")
+    LogMinFreeSwapThresholdInMB(414),
+
+    @Reloadable
+    @TypeConverterAttribute(Integer.class)
+    @DefaultValueAttribute("95")
+    LogMaxSwapUsedThresholdInPercentage(415),
+
     Invalid(65535);
 
     private int intValue;
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
index badfa07..83da993 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
@@ -279,6 +279,11 @@
         mSeverities.put(AuditLogType.USER_VDS_MAINTENANCE, 
AuditLogSeverity.NORMAL);
         mSeverities.put(AuditLogType.VDS_ALERT_FENCE_NO_PROXY_HOST, 
AuditLogSeverity.NORMAL);
         mSeverities.put(AuditLogType.VDS_LOW_MEM, AuditLogSeverity.WARNING);
+        mSeverities.put(AuditLogType.VDS_HIGH_MEM_USE, 
AuditLogSeverity.WARNING);
+        mSeverities.put(AuditLogType.VDS_HIGH_CPU_USE, 
AuditLogSeverity.WARNING);
+        mSeverities.put(AuditLogType.VDS_HIGH_NETWORK_USE, 
AuditLogSeverity.WARNING);
+        mSeverities.put(AuditLogType.VDS_HIGH_SWAP_USE, 
AuditLogSeverity.WARNING);
+        mSeverities.put(AuditLogType.VDS_LOW_SWAP, AuditLogSeverity.WARNING);
         
mSeverities.put(AuditLogType.VDS_STORAGE_CONNECTION_FAILED_BUT_LAST_VDS, 
AuditLogSeverity.ERROR);
         mSeverities.put(AuditLogType.VDS_STORAGES_CONNECTION_FAILED, 
AuditLogSeverity.ERROR);
         mSeverities.put(AuditLogType.VDS_STORAGE_VDS_STATS_FAILED, 
AuditLogSeverity.ERROR);
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
index 9e4c247..104266a 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -523,6 +523,11 @@
 CONNECT_STORAGE_POOL_FAILED=Failed to connect Host ${VdsName} to Storage Pool 
${StoragePoolName}
 STORAGE_DOMAIN_ERROR=The error message for connection ${Connection} returned 
by VDSM was: ${ErrorMessage}
 VDS_LOW_MEM=Available memory of host ${HostName} [${AvailableMemory} MB] is 
under defined threshold [${Threshold} MB].
+VDS_HIGH_MEM_USE=Used memory of host ${HostName} [${UsedMemory}%] is over 
defined threshold [${Threshold}%].
+VDS_HIGH_NETWORK_USE=Used Network resources of host ${HostName} 
[${UsedNetwork}%] is over defined threshold [${Threshold}%].
+VDS_HIGH_CPU_USE=Used CPU of host ${HostName} [${UsedCpu}%] is over defined 
threshold [${Threshold}%].
+VDS_HIGH_SWAP_USE=Used swap memory of host ${HostName} [${UsedSwap}%] is over 
defined threshold [${Threshold}%].
+VDS_LOW_SWAP=Available swap memory of host ${HostName} [${AvailableSwapMemory} 
MB] is under defined threshold [${Threshold} MB].
 UPDATE_OVF_FOR_STORAGE_POOL_FAILED=Failed to update VMs/Templates OVF data in 
Data Center ${StoragePoolName}.
 IMPORTEXPORT_FAILED_TO_IMPORT_VM=Failed to read VM '${ImportedVmName}' OVF, it 
may be corrupted
 IMPORTEXPORT_FAILED_TO_IMPORT_TEMPLATE=Failed to read Template '${Template}' 
OVF, it may be corrupted
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
index 60ac63f..d2b39fa 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
@@ -120,6 +120,9 @@
             VdsStatistics stat = _vds.getStatisticsData();
             _vdsManager.UpdateStatisticsData(stat);
             checkVdsMemoryThreshold(stat);
+            checkVdsCpuThreshold(stat);
+            checkVdsNetworkThreshold(stat);
+            checkVdsSwapThreshold(stat);
 
             final List<VdsNetworkStatistics> statistics = new 
LinkedList<VdsNetworkStatistics>();
             for (VdsNetworkInterface iface : _vds.getInterfaces()) {
@@ -258,14 +261,80 @@
      */
     private void checkVdsMemoryThreshold(VdsStatistics stat) {
 
-        Integer threshold = 
Config.GetValue(ConfigValues.LogPhysicalMemoryThresholdInMB);
-        if (stat.getmem_available() < threshold) {
+        Integer minAvailableThreshold = 
Config.GetValue(ConfigValues.LogPhysicalMemoryThresholdInMB);
+        Integer maxUsedPercentageThreshold = 
Config.GetValue(ConfigValues.LogMaxPhysicalMemoryUsedThresholdInPercentage);
+        if (stat.getmem_available() < minAvailableThreshold
+                || stat.getusage_mem_percent() > maxUsedPercentageThreshold) {
             AuditLogableBase logable = new AuditLogableBase();
             logable.setVdsId(stat.getId());
             logable.AddCustomValue("HostName", _vds.getvds_name());
             logable.AddCustomValue("AvailableMemory", 
stat.getmem_available().toString());
-            logable.AddCustomValue("Threshold", threshold.toString());
-            auditLog(logable, AuditLogType.VDS_LOW_MEM);
+            logable.AddCustomValue("UsedMemory", 
stat.getusage_mem_percent().toString());
+            logable.AddCustomValue("Threshold", stat.getmem_available() < 
minAvailableThreshold ?
+                    minAvailableThreshold.toString() :
+                    maxUsedPercentageThreshold.toString());
+            auditLog(logable, stat.getmem_available() < minAvailableThreshold 
? AuditLogType.VDS_LOW_MEM :
+                AuditLogType.VDS_HIGH_MEM_USE);
+        }
+    }
+
+    /**
+     * check if value is less than configurable threshold , if yes , generated 
event log message
+     *
+     * @param stat
+     */
+    private void checkVdsCpuThreshold(VdsStatistics stat) {
+
+        Integer maxUsedPercentageThreshold = 
Config.GetValue(ConfigValues.LogMaxCpuUsedThresholdInPercentage);
+        if (stat.getusage_cpu_percent() > maxUsedPercentageThreshold) {
+            AuditLogableBase logable = new AuditLogableBase();
+            logable.setVdsId(stat.getId());
+            logable.AddCustomValue("HostName", _vds.getvds_name());
+            logable.AddCustomValue("UsedCpu", 
stat.getusage_cpu_percent().toString());
+            logable.AddCustomValue("Threshold", 
maxUsedPercentageThreshold.toString());
+            auditLog(logable, AuditLogType.VDS_HIGH_CPU_USE);
+        }
+    }
+
+    /**
+     * check if value is less than configurable threshold , if yes , generated 
event log message
+     *
+     * @param stat
+     */
+    private void checkVdsNetworkThreshold(VdsStatistics stat) {
+
+        Integer maxUsedPercentageThreshold = 
Config.GetValue(ConfigValues.LogMaxNetworkUsedThresholdInPercentage);
+        if (stat.getusage_network_percent() > maxUsedPercentageThreshold) {
+            AuditLogableBase logable = new AuditLogableBase();
+            logable.setVdsId(stat.getId());
+            logable.AddCustomValue("HostName", _vds.getvds_name());
+            logable.AddCustomValue("UsedNetwork", 
stat.getusage_network_percent().toString());
+            logable.AddCustomValue("Threshold", 
maxUsedPercentageThreshold.toString());
+            auditLog(logable, AuditLogType.VDS_HIGH_NETWORK_USE);
+        }
+    }
+
+    /**
+     * check if value is less than configurable threshold , if yes , generated 
event log message
+     *
+     * @param stat
+     */
+    private void checkVdsSwapThreshold(VdsStatistics stat) {
+
+        Integer minAvailableThreshold = 
Config.GetValue(ConfigValues.LogPhysicalMemoryThresholdInMB);
+        Integer maxUsedPercentageThreshold =
+                
Config.GetValue(ConfigValues.LogMaxPhysicalMemoryUsedThresholdInPercentage);
+        Long swapUsedPercent = (stat.getswap_total() - stat.getswap_free()) / 
stat.getswap_total();
+        if (stat.getswap_free() < minAvailableThreshold || swapUsedPercent > 
maxUsedPercentageThreshold) {
+            AuditLogableBase logable = new AuditLogableBase();
+            logable.setVdsId(stat.getId());
+            logable.AddCustomValue("HostName", _vds.getvds_name());
+            logable.AddCustomValue("UsedSwap", swapUsedPercent.toString());
+            logable.AddCustomValue("AvailableSwapMemory", 
stat.getswap_free().toString());
+            logable.AddCustomValue("Threshold", stat.getswap_free() < 
minAvailableThreshold ?
+                    minAvailableThreshold.toString() : 
maxUsedPercentageThreshold.toString());
+            auditLog(logable, stat.getswap_free() < minAvailableThreshold ?
+                    AuditLogType.VDS_LOW_SWAP : 
AuditLogType.VDS_HIGH_SWAP_USE);
         }
     }
 


--
To view, visit http://gerrit.ovirt.org/10865
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id382c4688bdcf46f7b343ff0661893a97b5dc726
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: ofri masad <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to