use of com.vmware.ops.api.model.symptomdefinition.HTCondition 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;
}
use of com.vmware.ops.api.model.symptomdefinition.HTCondition 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);
}
Aggregations