Package org.rhq.core.domain.alert

Examples of org.rhq.core.domain.alert.AlertCondition


        ret.setName(universalName + ":" + name);
        ret.setPriority(AlertPriority.MEDIUM);
        ret.setConditionExpression(BooleanExpression.ANY);
        ret.setRecoveryId(0);

        AlertCondition ac = new AlertCondition();
        ac.setName(universalName + ":" + name);
        ac.setCategory(AlertConditionCategory.THRESHOLD);
        ac.setComparator(">");
        ac.setThreshold(0.75D);
        //for (MeasurementDefinition d : resourceType.getMetricDefinitions()) {
        //    if ("Calculated.HeapUsagePercentage".equals(d.getName())) {
        //        ac.setMeasurementDefinition(d);
        //        ac.setName(d.getDisplayName());
        //        break;
View Full Code Here


        newTemplate.setConditionExpression(BooleanExpression.ANY);
        newTemplate.setDescription(storageNodeHighHeapTemplate.getDescription());
        newTemplate.setRecoveryId(0);
        newTemplate.setEnabled(true);

        AlertCondition ac = new AlertCondition();
        ac.setCategory(AlertConditionCategory.THRESHOLD);
        ac.setComparator(">");
        ac.setThreshold(0.75D);

        List<Integer> measurementDefinitionIds = new ArrayList<Integer>(2);
        for (MeasurementDefinition d : resourceType.getMetricDefinitions()) {
            if ("Calculated.HeapUsagePercentage".equals(d.getName())) {
                measurementDefinitionIds.add(d.getId());
                ac.setMeasurementDefinition(d);
                ac.setName(d.getDisplayName());
            } else if ("{HeapMemoryUsage.used}".equals(d.getName())) {
                measurementDefinitionIds.add(d.getId());
            }
        }
        assert null != ac.getMeasurementDefinition() : "Did not find expected measurement definition [Calculated.HeapUsagePercentage] for "
            + resourceType;
        newTemplate.addCondition(ac);

        AlertDampening dampener = new AlertDampening(AlertDampening.Category.PARTIAL_COUNT);
        dampener.setPeriod(15);
View Full Code Here

        newTemplate.setDescription(storageNodeHighDiskUsageTemplate.getDescription());
        newTemplate.setRecoveryId(0);
        newTemplate.setEnabled(true);


        AlertCondition dataDiskUsedAlertCondition = new AlertCondition();
        dataDiskUsedAlertCondition.setCategory(AlertConditionCategory.THRESHOLD);
        dataDiskUsedAlertCondition.setComparator(">");
        dataDiskUsedAlertCondition.setThreshold(0.5D);

        AlertCondition totalDiskUsedAlertCondition = new AlertCondition();
        totalDiskUsedAlertCondition.setCategory(AlertConditionCategory.THRESHOLD);
        totalDiskUsedAlertCondition.setComparator(">");
        totalDiskUsedAlertCondition.setThreshold(0.75D);

        AlertCondition freeSpaveDataRatioAlertCondition = new AlertCondition();
        freeSpaveDataRatioAlertCondition.setCategory(AlertConditionCategory.THRESHOLD);
        freeSpaveDataRatioAlertCondition.setComparator("<");
        freeSpaveDataRatioAlertCondition.setThreshold(1.5D);

        List<Integer> measurementDefinitionIds = new ArrayList<Integer>(1);
        for (MeasurementDefinition d : resourceType.getMetricDefinitions()) {
            if (DATA_DISK_USED_PERCENTAGE_METRIC_NAME.equals(d.getName())) {
                measurementDefinitionIds.add(d.getId());
                dataDiskUsedAlertCondition.setMeasurementDefinition(d);
                dataDiskUsedAlertCondition.setName(d.getDisplayName());
            } else if (TOTAL_DISK_USED_PERCENTAGE_METRIC_NAME.equals(d.getName())) {
                measurementDefinitionIds.add(d.getId());
                totalDiskUsedAlertCondition.setMeasurementDefinition(d);
                totalDiskUsedAlertCondition.setName(d.getDisplayName());
            } else if (FREE_DISK_TO_DATA_SIZE_RATIO_METRIC_NAME.equals(d.getName())) {
                measurementDefinitionIds.add(d.getId());
                freeSpaveDataRatioAlertCondition.setMeasurementDefinition(d);
                freeSpaveDataRatioAlertCondition.setName(d.getDisplayName());
            }
        }

        newTemplate.addCondition(dataDiskUsedAlertCondition);
        newTemplate.addCondition(totalDiskUsedAlertCondition);
View Full Code Here

        newTemplate.setConditionExpression(BooleanExpression.ANY);
        newTemplate.setDescription(storageNodeSnapshotFailureTemplate.getDescription());
        newTemplate.setRecoveryId(0);
        newTemplate.setEnabled(true);

        AlertCondition snapshotFailureCondition = new AlertCondition();
        snapshotFailureCondition.setCategory(AlertConditionCategory.CONTROL);
        snapshotFailureCondition.setName(TAKE_SNAPSHOT_OPERATION_NAME);
        snapshotFailureCondition.setOption(OperationRequestStatus.FAILURE.name());
        newTemplate.addCondition(snapshotFailureCondition);

        AlertDampening dampener = new AlertDampening(AlertDampening.Category.NONE);
        newTemplate.setAlertDampening(dampener);
View Full Code Here

        newTemplate.setDescription(storageNodeMaintenanceOperationsFailureTemplate.getDescription());
        newTemplate.setRecoveryId(0);
        newTemplate.setEnabled(true);

        for (String operation : MAINTENANCE_OPERATIONS) {
            AlertCondition snapshotFailureCondition = new AlertCondition();
            snapshotFailureCondition.setCategory(AlertConditionCategory.CONTROL);
            snapshotFailureCondition.setName(operation);
            snapshotFailureCondition.setOption(OperationRequestStatus.FAILURE.name());
            newTemplate.addCondition(snapshotFailureCondition);
        }

        AlertDampening dampener = new AlertDampening(AlertDampening.Category.NONE);
        newTemplate.setAlertDampening(dampener);
View Full Code Here

                if (alert.getConditionLogs().size() > 1) {
                    results.add(new AlertWithLatestConditionLog(alert, "Multiple Conditions", "--", recoveryInfo));
                } else if (alert.getConditionLogs().size() == 1) {
                    AlertConditionLog log = alert.getConditionLogs().iterator().next();
                    AlertCondition condition = log.getCondition();
                    String displayText = AlertDefUtil.formatAlertConditionForDisplay(condition, request);

                    String firedValue = log.getValue();
                    if (condition.getMeasurementDefinition() != null) {
                        firedValue = MeasurementConverter.format(Double.valueOf(log.getValue()), condition
                            .getMeasurementDefinition().getUnits(), true);
                    }

                    results.add(new AlertWithLatestConditionLog(alert, displayText, firedValue, recoveryInfo));
                } else {
View Full Code Here

        em.persist(a);

        AlertNotificationLog anl = new AlertNotificationLog(a, "dummy", ResultState.SUCCESS, "message");
        em.persist(anl);

        AlertCondition ac = ad.getConditions().iterator().next();
        AlertConditionLog acl = new AlertConditionLog(ac, timestamp);
        acl.setAlert(a);
        acl.setValue("dummy value");
        em.persist(acl);
View Full Code Here

            ad.setAlertDampening(new AlertDampening(AlertDampening.Category.NONE));
            ad.setConditionExpression(BooleanExpression.ALL);
            ad.setRecoveryId(0);
            em.persist(ad);

            AlertCondition ac = new AlertCondition(ad, AlertConditionCategory.AVAILABILITY);
            ac.setComparator("==");
            em.persist(ac);
            ad.addCondition(ac);

            EventDefinition ed = new EventDefinition(resourceType, "DataPurgeJobTestEventDefinition");
            em.persist(ed);
View Full Code Here

                condId = cond.getId();
                break;
            }
        }
        assert condId > 0 : "failed to get the condition ID - something is wrong with test setup";
        AlertCondition conditionWithLogs = getAlertConditionWithLogs(condId); // should eagerly load logs
        Set<AlertConditionLog> logs = conditionWithLogs.getConditionLogs();
        assert logs != null && logs.size() > 0 : "missing condition log - we should have one that was generated";
        AlertConditionLog log = logs.iterator().next();
        assert log.getAlert() == null : "condition should not have fired an alert: " + logs;

        // purge the resource fully, which should remove all alert defs and alert conditions and condition logs
View Full Code Here

        // create our resource with alert definition
        MeasurementDefinition metricDef = createResourceWithMetricSchedule();
        AlertDefinition alertDef = createAlertDefinitionWithOneInsideRangeCondition(metricDef, resource.getId());

        assert alertDef.getConditions().size() == 1 : "1 alertDef condition should exist";
        AlertCondition condition = alertDef.getConditions().iterator().next();
        int conditionId = condition.getId();

        // re-load the resource so we get the measurement schedule
        Resource resourceWithSchedules = loadResourceWithSchedules(resource.getId());
        MeasurementSchedule schedule = resourceWithSchedules.getSchedules().iterator().next();

        // simulate a measurement report coming from the agent - one values that fits in our range, so 1 alert is fired
        MeasurementScheduleRequest request = new MeasurementScheduleRequest(schedule);
        MeasurementReport report = new MeasurementReport();
        report.addData(new MeasurementDataNumeric(getTimestamp(15), request, 50.0)); // 50 < 60 AND 50 > 40
        MeasurementDataManagerLocal dataManager = LookupUtil.getMeasurementDataManager();
        dataManager.mergeMeasurementReport(report);

        // wait for our JMS messages to process and see if we get any alerts
        Thread.sleep(5000);

        // make sure one alert was triggered
        List<Alert> alerts = getAlerts(resourceWithSchedules.getId());
        assert alerts.size() == 1 : "1 alert should have fired: " + alerts;
        Alert alert = alerts.get(0);

        assert alert.getConditionLogs().size() == 1 : "1 condition log should exist";
        AlertConditionLog conditionLog = alert.getConditionLogs().iterator().next();
        Assert.assertEquals(conditionLog.getCondition().getId(), conditionId,
            "original condition should have been associated with the alert");

        // update a non-condition aspect of the def and then update the def
        String updatedDesc = "Updated Description";
        alertDef.setDescription(updatedDesc);
        AlertDefinition updatedAlertDef = LookupUtil.getAlertDefinitionManager().updateAlertDefinition(getOverlord(),
            alertDef.getId(), alertDef, false); // note that resetMatching is false
        assert updatedDesc.equals(updatedAlertDef.getDescription()) : "Description should be updated";
        assert updatedAlertDef.getConditions().size() == 1 : "1 alertDef condition should exist after the update";
        assert updatedAlertDef.getConditions().iterator().next().getId() == condition.getId() : "condition should not be updated";

        // get the alert again, and make sure it still has a log with the same condition
        alerts = getAlerts(resourceWithSchedules.getId());
        assert alerts.size() == 1 : "1 alert should have fired: " + alerts;
        alert = alerts.get(0);

        assert alert.getConditionLogs().size() == 1 : "1 condition log should exist after the update";
        conditionLog = alert.getConditionLogs().iterator().next();
        Assert.assertEquals(conditionLog.getCondition().getId(), conditionId,
            "original condition should still have been associated with the alert");

        // update the condition on the def and then update the def
        condition.setThreshold(41.0);
        updatedAlertDef = LookupUtil.getAlertDefinitionManager().updateAlertDefinition(getOverlord(), alertDef.getId(),
            alertDef, true); // note that resetMatching is true
        assert updatedAlertDef.getConditions().size() == 1 : "1 alertDef condition should exist after the update";
        assert updatedAlertDef.getConditions().iterator().next().getId() != condition.getId() : "condition should be updated";

        // get the alert again, and make sure it still has a log with the same condition
        alerts = getAlerts(resourceWithSchedules.getId());
        assert alerts.size() == 1 : "1 alert should have fired: " + alerts;
        alert = alerts.get(0);
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.alert.AlertCondition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.