Examples of AlertCondition


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

    public AlertConditionBaselineCategoryComposite(
            int cid, AlertConditionCategory ccategory, String cname, String ccomparator, Double cthreshold, String coption, Integer triggerId,
            Integer scheduleId, Integer baselineId,
        Double minValue, Double meanValue, Double maxValue, DataType dataType) {
        super(new AlertCondition(cid, ccategory, cname, ccomparator, cthreshold, coption, triggerId),
                scheduleId, dataType);
        this.baselineId = baselineId;
        this.minValue = minValue;
        this.meanValue = meanValue;
        this.maxValue = maxValue;
View Full Code Here

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

    private final Integer resourceId;

    public AlertConditionEventCategoryComposite(
            int cid, AlertConditionCategory ccategory, String cname, String ccomparator, Double cthreshold, String coption, Integer triggerId,
            Integer resourceId) {
        super(new AlertCondition(cid, ccategory, cname, ccomparator, cthreshold, coption, triggerId));
        this.resourceId = resourceId;
    }
View Full Code Here

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

    private final String value;

    public AlertConditionTraitCategoryComposite(
            int cid, AlertConditionCategory ccategory, String cname, String ccomparator, Double cthreshold, String coption, Integer triggerId,
            Integer scheduleId, String value) {
        super(new AlertCondition(cid, ccategory, cname, ccomparator, cthreshold, coption, triggerId),
                scheduleId, DataType.TRAIT);
        this.value = value;
    }
View Full Code Here

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

    public AlertConditionControlCategoryComposite(
            int cid, AlertConditionCategory ccategory, String cname, String ccomparator, Double cthreshold, String coption, Integer triggerId,
            Integer resourceId,
        Integer operationDefinitionId) {
        super(new AlertCondition(cid, ccategory, cname, ccomparator, cthreshold, coption, triggerId));
        this.resourceId = resourceId;
        this.operationDefinitionId = operationDefinitionId;
    }
View Full Code Here

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

                em.persist(dynamicSchedule);
            }
        });

        alertDefinition = new AlertDefinition();
        AlertCondition cond = new AlertCondition(alertDefinition, AlertConditionCategory.CHANGE);
        cond.setName(DYNAMIC_DEF_NAME);
        cond.setMeasurementDefinition(dynamicMeasuremenDef);
        alertDefinition.setName("liveDataTestAlert");
        alertDefinition.setResource(resource);
        alertDefinition.setPriority(AlertPriority.MEDIUM);
        alertDefinition.setRecoveryId(0);
        alertDefinition.setAlertDampening(new AlertDampening(AlertDampening.Category.NONE));
View Full Code Here

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

        if (conditionLogs.size() > 1) {
            conditionText = MSG.view_alerts_field_condition_text_many();
            conditionValue = "--";
        } else if (conditionLogs.size() == 1) {
            AlertConditionLog conditionLog = conditionLogs.iterator().next();
            AlertCondition condition = conditionLog.getCondition();
            conditionText = AlertFormatUtility.formatAlertConditionForDisplay(condition);
            conditionValue = conditionLog.getValue();
            if (condition.getMeasurementDefinition() != null) {
                try {
                    conditionValue = MeasurementConverterClient.format(Double.valueOf(conditionLog.getValue()),
                        condition.getMeasurementDefinition().getUnits(), true);
                } catch (Exception e) {
                    // the condition log value was probably not a number (most likely a trait). Ignore this exception.
                    // even if any other errors occur trying to format the value, ignore this and just use the raw value string
                }
            }
        } else {
            conditionText = MSG.view_alerts_field_condition_text_none();
            conditionValue = "--";
        }
        record.setAttribute("conditionText", conditionText);
        if (conditionValue.contains("extraInfo=")) {
            conditionValue = conditionValue.replaceFirst("extraInfo=\\[","");
            conditionValue = conditionValue.substring(0,conditionValue.length()-1);
        }
        record.setAttribute("conditionValue", conditionValue);

        // We also need the'raw' notification data to show in details
        DataClass[] conditions = new DataClass[from.getConditionLogs().size()];
        int i = 0;
        for (AlertConditionLog log : from.getConditionLogs()) {
            AlertCondition condition = log.getCondition();
            DataClass dc = new DataClass();
            dc.setAttribute("text", AlertFormatUtility.formatAlertConditionForDisplay(condition));
            String value = log.getValue();
            if (condition.getMeasurementDefinition() != null) {
                try {
                    value = MeasurementConverterClient.format(Double.valueOf(log.getValue()), condition
                        .getMeasurementDefinition().getUnits(), true);
                } catch (Exception e) {
                    // the condition log value was probably not a number (most likely a trait). Ignore this exception.
                    // even if any other errors occur trying to format the value, ignore this and just use the raw value string
                }
View Full Code Here

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

            } else {
                calltimeCategory = false;
                category = AlertConditionCategory.valueOf(selectedCategory);
            }

            AlertCondition newCondition = new AlertCondition();
            newCondition.setCategory(category);

            switch (category) {
            case AVAILABILITY: {
                newCondition.setName(form.getValueAsString(AVAILABILITY_ITEMNAME));
                newCondition.setComparator(null);
                newCondition.setThreshold(null);
                newCondition.setOption(null);
                newCondition.setMeasurementDefinition(null);
                break;
            }

            case AVAIL_DURATION: {
                newCondition.setName(form.getValueAsString(AVAILABILITY_DURATION_ITEMNAME));
                newCondition.setComparator(null);
                newCondition.setThreshold(null);
                // entered in minutes, converted to seconds by DurationItem, and stored in seconds
                int duration = Integer.valueOf(form.getValueAsString(AVAILABILITY_DURATION_VAL_ITEMNAME));
                newCondition.setOption(String.valueOf(duration));
                newCondition.setMeasurementDefinition(null);
                break;
            }

            case THRESHOLD: {
                if (!calltimeCategory) {
                    MeasurementDefinition measDef = getMeasurementDefinition(form
                        .getValueAsString(THRESHOLD_METRIC_ITEMNAME));
                    newCondition.setName(measDef.getDisplayName());
                    newCondition.setThreshold(getMeasurementValue(measDef,
                        form.getValueAsString(THRESHOLD_ABSVALUE_ITEMNAME)));
                    newCondition.setComparator(form.getValueAsString(THRESHOLD_COMPARATOR_ITEMNAME));
                    newCondition.setOption(null);
                    newCondition.setMeasurementDefinition(measDef);
                } else {
                    MeasurementDefinition measDef = getMeasurementDefinition(form
                        .getValueAsString(CALLTIME_THRESHOLD_METRIC_ITEMNAME));
                    newCondition.setName(form.getValueAsString(CALLTIME_THRESHOLD_REGEX_ITEMNAME));
                    newCondition.setThreshold(getMeasurementValue(measDef,
                        form.getValueAsString(CALLTIME_THRESHOLD_ABSVALUE_ITEMNAME)));
                    newCondition.setComparator(form.getValueAsString(CALLTIME_THRESHOLD_COMPARATOR_ITEMNAME));
                    newCondition.setOption(form.getValueAsString(CALLTIME_THRESHOLD_MINMAXAVG_ITEMNAME));
                    newCondition.setMeasurementDefinition(measDef);
                }
                break;
            }

            case BASELINE: {
                MeasurementDefinition measDef = getMeasurementDefinition(form
                    .getValueAsString(BASELINE_METRIC_ITEMNAME));
                newCondition.setName(measDef.getDisplayName());
                newCondition.setThreshold(getMeasurementValueByUnits(MeasurementUnits.PERCENTAGE,
                    form.getValueAsString(BASELINE_PERCENTAGE_ITEMNAME)));
                newCondition.setComparator(form.getValueAsString(BASELINE_COMPARATOR_ITEMNAME));
                newCondition.setOption(form.getValueAsString(BASELINE_SELECTION_ITEMNAME));
                newCondition.setMeasurementDefinition(measDef);
                break;
            }

            case CHANGE: {
                if (!calltimeCategory) {
                    MeasurementDefinition measDef = getMeasurementDefinition(form
                        .getValueAsString(CHANGE_METRIC_ITEMNAME));
                    newCondition.setName(measDef.getDisplayName());
                    newCondition.setComparator(null);
                    newCondition.setThreshold(null);
                    newCondition.setOption(null);
                    newCondition.setMeasurementDefinition(measDef);
                } else {
                    MeasurementDefinition measDef = getMeasurementDefinition(form
                        .getValueAsString(CALLTIME_CHANGE_METRIC_ITEMNAME));
                    newCondition.setName(form.getValueAsString(CALLTIME_CHANGE_REGEX_ITEMNAME));
                    newCondition.setThreshold(getMeasurementValueByUnits(MeasurementUnits.PERCENTAGE,
                        form.getValueAsString(CALLTIME_CHANGE_PERCENTAGE_ITEMNAME)));
                    newCondition.setComparator(form.getValueAsString(CALLTIME_CHANGE_COMPARATOR_ITEMNAME));
                    newCondition.setOption(form.getValueAsString(CALLTIME_CHANGE_MINMAXAVG_ITEMNAME));
                    newCondition.setMeasurementDefinition(measDef);
                }
                break;
            }

            case TRAIT: {
                MeasurementDefinition measDef = getMeasurementDefinition(form.getValueAsString(TRAIT_METRIC_ITEMNAME));
                newCondition.setName(measDef.getDisplayName());
                newCondition.setComparator(null);
                newCondition.setThreshold(null);
                newCondition.setOption(form.getValueAsString(TRAIT_REGEX_ITEMNAME));
                newCondition.setMeasurementDefinition(measDef);
                break;
            }

            case CONTROL: {
                newCondition.setName(form.getValueAsString(OPERATION_NAME_ITEMNAME));
                newCondition.setComparator(null);
                newCondition.setThreshold(null);
                newCondition.setOption(form.getValueAsString(OPERATION_RESULTS_ITEMNAME));
                newCondition.setMeasurementDefinition(null);
                break;
            }

            case EVENT: {
                newCondition.setName(form.getValueAsString(EVENT_SEVERITY_ITEMNAME));
                newCondition.setComparator(null);
                newCondition.setThreshold(null);
                Object regex1 = form.getValue(EVENT_REGEX_ITEMNAME);
                Object regex2 = form.getValue(EVENT_SOURCE_PATH_REGEX_ITEMNAME);
                newCondition.setOption((regex1 == null ? "" : regex1) + AlertCondition.ADHOC_SEPARATOR
                    + (regex2 == null ? "" : regex2));
                newCondition.setMeasurementDefinition(null);
                break;
            }

            case RESOURCE_CONFIG: {
                newCondition.setName(null);
                newCondition.setComparator(null);
                newCondition.setThreshold(null);
                newCondition.setOption(null);
                newCondition.setMeasurementDefinition(null);
                break;
            }

            case DRIFT: {
                newCondition.setName(form.getValueAsString(DRIFT_DEFNAME_REGEX_ITEMNAME));
                newCondition.setComparator(null);
                newCondition.setThreshold(null);
                newCondition.setOption(form.getValueAsString(DRIFT_PATHNAME_REGEX_ITEMNAME));
                newCondition.setMeasurementDefinition(null);
                break;
            }

            case RANGE: {
                MeasurementDefinition measDef = getMeasurementDefinition(form.getValueAsString(RANGE_METRIC_ITEMNAME));
                newCondition.setName(measDef.getDisplayName());
                newCondition.setThreshold(getMeasurementValue(measDef,
                    form.getValueAsString(RANGE_LO_ABSVALUE_ITEMNAME)));
                newCondition.setComparator(form.getValueAsString(RANGE_COMPARATOR_ITEMNAME));
                newCondition.setOption(getMeasurementValue(measDef, form.getValueAsString(RANGE_HI_ABSVALUE_ITEMNAME))
                    .toString());
                newCondition.setMeasurementDefinition(measDef);
                break;
            }

            default: {
                CoreGUI.getErrorHandler().handleError(
                    MSG.view_alert_common_tab_invalid_condition_category(category.name())); // should never happen
                break;
            }
            }
            if (editMode) {
                if (existingCondition.getId() != 0) {
                    // get rid of the id, because of the equals method
                    AlertCondition conditionWithoutId = new AlertCondition(existingCondition);
                    if (!conditionWithoutId.equals(newCondition)) {
                        // there was a change
                        this.modifiedConditions.put(existingCondition.getId(), newCondition);
                        existingCondition.setMeasurementDefinition(newCondition.getMeasurementDefinition());
                        existingCondition.setName(newCondition.getName());
                        existingCondition.setComparator(newCondition.getComparator());
View Full Code Here

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

        Response.ResponseBuilder builder;

        if (type.equals(MediaType.APPLICATION_XML_TYPE)) {
            List<StringValue> result = new ArrayList<StringValue>(conditions.size());
            for (AlertConditionLog log : conditions) {
                AlertCondition condition = log.getCondition();
                String entry = String.format("category='%s', name='%s', comparator='%s', threshold='%s', option='%s' : %s",
                        condition.getCategory(), condition.getName(), condition.getComparator(), condition.getThreshold(), condition.getOption(), log.getValue() );
                StringValue sv = new StringValue(entry);
                result.add(sv);
            }
            GenericEntity<List<StringValue>> entity = new GenericEntity<List<StringValue>>(result){};
            builder = Response.ok(entity);
        }
        else {
            List<String> result = new ArrayList<String>(conditions.size());

            for (AlertConditionLog log : conditions) {
                AlertCondition condition = log.getCondition();
                String entry = String.format("category='%s', name='%s', comparator='%s', threshold='%s', option='%s' : %s",
                        condition.getCategory(), condition.getName(), condition.getComparator(), condition.getThreshold(), condition.getOption(), log.getValue() );
                result.add(entry);
            }
            if (type.equals(MediaType.TEXT_HTML_TYPE)) {
                builder = Response.ok(renderTemplate("genericStringList.ftl",result),type);
            } else {
View Full Code Here

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

            throw new IllegalStateException("Availabilities table is not empty");
        }
        systemManager.vacuum(overlord, new String[] { "rhq_availability" });

        // Set up an alert definition on one resource
        AlertCondition goingDown = new AlertCondition();
        goingDown.setCategory(AlertConditionCategory.AVAILABILITY);
        goingDown.setComparator("==");
        goingDown.setOption(AvailabilityType.DOWN.toString());

        AlertDefinition def = new AlertDefinition();
        def.addCondition(goingDown);
        def.setName("Test alert definition");
        def.setPriority(AlertPriority.MEDIUM);
View Full Code Here

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

            table.addTableAction(MSG.common_button_delete(), MSG
                .view_alert_definition_condition_editor_delete_confirm(), ButtonColor.RED, new AbstractTableAction(
                TableActionEnablement.ANY) {
                public void executeAction(ListGridRecord[] selection, Object actionValue) {
                    for (ListGridRecord record : selection) {
                        AlertCondition condition = getDataSource().copyValues(record);
                        conditions.remove(condition);
                        modifiedConditions.remove(condition);
                        updated = true;
                    }
                    refresh();
                }
            });

            table.addTableAction(MSG.view_alert_definition_editCondition(), null, ButtonColor.GRAY, new AbstractTableAction(TableActionEnablement.SINGLE) {
                public void executeAction(ListGridRecord[] selection, Object actionValue) {
                    AlertCondition condition = getDataSource().copyValues(selection[0]);
                    showConditionEditor(condition);
                }
            });

        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.