Search in sources :

Example 1 with SymptomDefinition

use of com.vmware.ops.api.model.symptomdefinition.SymptomDefinition in project flowgate by vmware.

the class AlertClient method checkPredefinedSymptoms.

private Map<String, SymptomDefinition> checkPredefinedSymptoms() {
    Map<String, SymptomDefinition> existSymptoms = getPredefinedSymptoms();
    if (existSymptoms.size() < predefinedSymptomNames.size()) {
        Set<String> missingSymptoms = new HashSet<String>(predefinedSymptomNames);
        missingSymptoms.removeAll(existSymptoms.keySet());
        createPredefinedSymptoms(missingSymptoms, existSymptoms);
    } else {
        // check whether we need to update the threshold of the symptoms
        List<SensorSetting> sensorSettings = new ArrayList<SensorSetting>();
        SensorSetting backTempSetting = new SensorSetting();
        backTempSetting.setMaxNum(35);
        backTempSetting.setType(MetricName.SERVER_BACK_TEMPREATURE);
        sensorSettings.add(backTempSetting);
        SensorSetting frontTempSetting = new SensorSetting();
        frontTempSetting.setMaxNum(35);
        frontTempSetting.setType(MetricName.SERVER_FRONT_TEMPERATURE);
        sensorSettings.add(frontTempSetting);
        SensorSetting backHumiditySetting = new SensorSetting();
        backHumiditySetting.setMaxNum(75);
        backHumiditySetting.setType(MetricName.SERVER_BACK_HUMIDITY);
        sensorSettings.add(backHumiditySetting);
        SensorSetting frontHumiditySetting = new SensorSetting();
        frontHumiditySetting.setMaxNum(75);
        frontHumiditySetting.setType(MetricName.SERVER_FRONT_HUMIDITY);
        sensorSettings.add(frontHumiditySetting);
        SensorSetting currentLoadSetting = new SensorSetting();
        currentLoadSetting.setMaxNum(67);
        currentLoadSetting.setType(MetricName.PDU_CURRENT_LOAD);
        sensorSettings.add(currentLoadSetting);
        Map<String, SensorSetting> symptomCondtionValues = getSymptomCondtionValues(sensorSettings);
        SymptomDefinitionsClient sd = getClient().symptomDefinitionsClient();
        for (SymptomDefinition symptom : existSymptoms.values()) {
            HTCondition condition = (HTCondition) symptom.getState().getCondition();
            SensorSetting sensorSetting = symptomCondtionValues.get(symptom.getName());
            if (sensorSetting != null) {
                if (!condition.getValue().equals((String.valueOf(sensorSetting.getMaxNum())))) {
                    condition.setValue(String.valueOf(sensorSetting.getMaxNum()));
                    sd.updateSymptomDefinition(symptom);
                }
            }
        }
    }
    return existSymptoms;
}
Also used : SymptomDefinition(com.vmware.ops.api.model.symptomdefinition.SymptomDefinition) ArrayList(java.util.ArrayList) HTCondition(com.vmware.ops.api.model.symptomdefinition.HTCondition) SensorSetting(com.vmware.flowgate.common.model.SensorSetting) SymptomDefinitionsClient(com.vmware.ops.api.client.controllers.SymptomDefinitionsClient) HashSet(java.util.HashSet)

Example 2 with SymptomDefinition

use of com.vmware.ops.api.model.symptomdefinition.SymptomDefinition in project flowgate by vmware.

the class AlertClient method createEnvrionmentSymptom.

protected SymptomDefinition createEnvrionmentSymptom(String name, int waitCycles, int cancleCycles, Criticality serverity, String conditionKey, CompareOperator conditionOperator, String value) {
    SymptomDefinitionsClient sd = getClient().symptomDefinitionsClient();
    SymptomDefinition aSymptomDefinition = new SymptomDefinition();
    aSymptomDefinition.setName(name);
    aSymptomDefinition.setAdapterKindKey(VROConsts.ADPTERKIND_VMARE_KEY);
    aSymptomDefinition.setResourceKindKey(VROConsts.RESOURCEKIND_HOSTSYSTEM_KEY);
    aSymptomDefinition.setWaitCycles(waitCycles);
    aSymptomDefinition.setCancelCycles(cancleCycles);
    SymptomState symptomState = new SymptomState();
    symptomState.setSeverity(serverity);
    HTCondition condition = new HTCondition();
    condition.setKey(conditionKey);
    condition.setOperator(conditionOperator);
    // must set threshold type to STATKEY and set the TargetKey
    condition.setThresholdType(ThresholdType.STATIC);
    // condition.setTargetKey("cpu|availablemhz");
    condition.setValue(value);
    // condition.setValueType(Condition.ValueTypeEnum.NUMERIC); // necessary only when value is a string
    condition.setInstanced(false);
    symptomState.setCondition(condition);
    aSymptomDefinition.setState(symptomState);
    aSymptomDefinition = sd.createSymptomDefinition(aSymptomDefinition);
    SymptomDefinitionQuery sdq = new SymptomDefinitionQuery();
    sdq.setAdapterKind(VROConsts.ADPTERKIND_VMARE_KEY);
    sdq.setResourceKind(VROConsts.RESOURCEKIND_HOSTSYSTEM_KEY);
    sdq.setId(new String[] { aSymptomDefinition.getId() });
    SymptomDefinitions allSymptoms = sd.querySymptomDefinitions(sdq, null);
    return allSymptoms.getSymptomDefinitions().get(0);
}
Also used : SymptomState(com.vmware.ops.api.model.symptomdefinition.SymptomState) SymptomDefinitionQuery(com.vmware.ops.api.model.symptomdefinition.SymptomDefinitionQuery) SymptomDefinition(com.vmware.ops.api.model.symptomdefinition.SymptomDefinition) HTCondition(com.vmware.ops.api.model.symptomdefinition.HTCondition) SymptomDefinitionsClient(com.vmware.ops.api.client.controllers.SymptomDefinitionsClient) SymptomDefinitions(com.vmware.ops.api.model.symptomdefinition.SymptomDefinition.SymptomDefinitions)

Example 3 with SymptomDefinition

use of com.vmware.ops.api.model.symptomdefinition.SymptomDefinition in project flowgate by vmware.

the class AlertClient method getPredefinedSymptoms.

protected Map<String, SymptomDefinition> getPredefinedSymptoms() {
    SymptomDefinitionsClient sdc = getClient().symptomDefinitionsClient();
    SymptomDefinitionQuery sdq = new SymptomDefinitionQuery();
    sdq.setAdapterKind(VROConsts.ADPTERKIND_VMARE_KEY);
    sdq.setResourceKind(VROConsts.RESOURCEKIND_HOSTSYSTEM_KEY);
    Map<String, SymptomDefinition> result = new HashMap<String, SymptomDefinition>();
    for (SymptomDefinition sd : sdc.querySymptomDefinitions(sdq, null).getSymptomDefinitions()) {
        if (predefinedSymptomNames.contains(sd.getName())) {
            result.put(sd.getName(), sd);
        }
    }
    return result;
}
Also used : SymptomDefinitionQuery(com.vmware.ops.api.model.symptomdefinition.SymptomDefinitionQuery) HashMap(java.util.HashMap) SymptomDefinition(com.vmware.ops.api.model.symptomdefinition.SymptomDefinition) SymptomDefinitionsClient(com.vmware.ops.api.client.controllers.SymptomDefinitionsClient)

Aggregations

SymptomDefinitionsClient (com.vmware.ops.api.client.controllers.SymptomDefinitionsClient)3 SymptomDefinition (com.vmware.ops.api.model.symptomdefinition.SymptomDefinition)3 HTCondition (com.vmware.ops.api.model.symptomdefinition.HTCondition)2 SymptomDefinitionQuery (com.vmware.ops.api.model.symptomdefinition.SymptomDefinitionQuery)2 SensorSetting (com.vmware.flowgate.common.model.SensorSetting)1 SymptomDefinitions (com.vmware.ops.api.model.symptomdefinition.SymptomDefinition.SymptomDefinitions)1 SymptomState (com.vmware.ops.api.model.symptomdefinition.SymptomState)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1