Search in sources :

Example 21 with AuditLogType

use of org.ovirt.engine.core.common.AuditLogType in project ovirt-engine by oVirt.

the class GlusterUtil method alertVolumeLimitReached.

private boolean alertVolumeLimitReached(final GlusterVolumeEntity volume, boolean checkHardLimit) {
    AuditLogType logType = checkHardLimit ? AuditLogType.GLUSTER_VOLUME_SNAPSHOT_HARD_LIMIT_REACHED : AuditLogType.GLUSTER_VOLUME_SNAPSHOT_SOFT_LIMIT_REACHED;
    List<AuditLog> limitAlerts = auditLogDao.getByVolumeIdAndType(volume.getId(), logType.getValue());
    if (!limitAlerts.isEmpty()) {
        for (AuditLog alert : limitAlerts) {
            if (!alert.isDeleted()) {
                return true;
            }
        }
    }
    // Alert
    boolean limitReached = checkHardLimit ? glusterDBUtils.isVolumeSnapshotHardLimitReached(volume.getId()) : glusterDBUtils.isVolumeSnapshotSoftLimitReached(volume.getId());
    if (limitReached) {
        glusterAuditLogUtil.logAuditMessage(volume.getClusterId(), volume.getClusterName(), volume, null, logType, volumeAsMap(volume));
        return true;
    }
    return false;
}
Also used : AuditLogType(org.ovirt.engine.core.common.AuditLogType) AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog)

Example 22 with AuditLogType

use of org.ovirt.engine.core.common.AuditLogType in project ovirt-engine by oVirt.

the class HostMonitoring method checkVdsSwapThreshold.

/**
 * check if value is less than configurable threshold , if yes , generated event list message
 */
private void checkVdsSwapThreshold(VdsStatistics stat) {
    final double THRESHOLD = 0.98;
    Integer minAvailableThreshold = Config.getValue(ConfigValues.LogSwapMemoryThresholdInMB);
    Integer maxUsedPercentageThreshold = Config.getValue(ConfigValues.LogMaxSwapMemoryUsedThresholdInPercentage);
    if (stat.getSwapTotal() == null || stat.getSwapFree() == null || stat.getSwapTotal() == 0) {
        return;
    }
    Long swapUsedPercent = (stat.getSwapTotal() - stat.getSwapFree()) / stat.getSwapTotal();
    // Allow the space to be up to 2% lower than as defined in configuration
    Long allowedMinAvailableThreshold = Math.round(minAvailableThreshold.doubleValue() * THRESHOLD);
    AuditLogType valueToLog = stat.getSwapFree() < allowedMinAvailableThreshold ? AuditLogType.VDS_LOW_SWAP : AuditLogType.VDS_HIGH_SWAP_USE;
    if (stat.getSwapFree() < allowedMinAvailableThreshold || swapUsedPercent > maxUsedPercentageThreshold) {
        AuditLogable logable = createAuditLogableForHost();
        logable.addCustomValue("HostName", vds.getName());
        logable.addCustomValue("UsedSwap", swapUsedPercent.toString());
        logable.addCustomValue("AvailableSwapMemory", stat.getSwapFree().toString());
        logable.addCustomValue("Threshold", stat.getSwapFree() < allowedMinAvailableThreshold ? minAvailableThreshold.toString() : maxUsedPercentageThreshold.toString());
        auditLog(logable, valueToLog);
    }
}
Also used : AuditLogType(org.ovirt.engine.core.common.AuditLogType) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)

Example 23 with AuditLogType

use of org.ovirt.engine.core.common.AuditLogType in project ovirt-engine by oVirt.

the class HostMonitoring method checkVdsMemoryThreshold.

/**
 * check if value is less than configurable threshold , if yes , generated event list message
 */
private void checkVdsMemoryThreshold(VdsStatistics stat) {
    Integer minAvailableThreshold = Config.getValue(ConfigValues.LogPhysicalMemoryThresholdInMB);
    Integer maxUsedPercentageThreshold = Config.getValue(ConfigValues.LogMaxPhysicalMemoryUsedThresholdInPercentage);
    if (stat.getMemFree() == null || stat.getUsageMemPercent() == null) {
        return;
    }
    AuditLogType valueToLog = stat.getMemFree() < minAvailableThreshold ? AuditLogType.VDS_LOW_MEM : AuditLogType.VDS_HIGH_MEM_USE;
    if (stat.getMemFree() < minAvailableThreshold || stat.getUsageMemPercent() > maxUsedPercentageThreshold) {
        AuditLogable logable = createAuditLogableForHost();
        logable.addCustomValue("HostName", vds.getName());
        logable.addCustomValue("AvailableMemory", stat.getMemFree().toString());
        logable.addCustomValue("UsedMemory", stat.getUsageMemPercent().toString());
        logable.addCustomValue("Threshold", stat.getMemFree() < minAvailableThreshold ? minAvailableThreshold.toString() : maxUsedPercentageThreshold.toString());
        auditLog(logable, valueToLog);
    }
}
Also used : AuditLogType(org.ovirt.engine.core.common.AuditLogType) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)

Aggregations

AuditLogType (org.ovirt.engine.core.common.AuditLogType)23 AuditLogable (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)8 AuditLogableImpl (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)5 AuditLogDirector (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector)4 AuditLogableBase (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 StandardCharsets (java.nio.charset.StandardCharsets)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 MissingResourceException (java.util.MissingResourceException)1 Objects (java.util.Objects)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1