public static void saveMonitorEventValues(HandlerContext handlerCtx) {
try{
String configName = (String) handlerCtx.getInputValue("ConfigName");
String ruleName = (String) handlerCtx.getInputValue("RuleName");
ConfigConfig config = AMXUtil.getConfig(configName);
ManagementRuleConfig mgRuleConfig = config.getManagementRulesConfig().getManagementRuleConfigMap().get(ruleName);
mgRuleConfig.setEnabled(((Boolean)handlerCtx.getInputValue("Status")).booleanValue());
mgRuleConfig.setDescription((String)handlerCtx.getInputValue("RuleDesc"));
mgRuleConfig.getEventConfig().setRecordEvent(((Boolean)handlerCtx.getInputValue("RecordEvent")).booleanValue());
mgRuleConfig.getEventConfig().setLevel((String)handlerCtx.getInputValue("LogLevel"));
mgRuleConfig.getEventConfig().setDescription((String)handlerCtx.getInputValue("EventDesc"));
String obsMbean = (String)handlerCtx.getInputValue("ObservedMbean");
String obsAttr = (String)handlerCtx.getInputValue("ObservedAttr");
String granularity = (String)handlerCtx.getInputValue("Granularity");
String monitorType = mgRuleConfig.getEventConfig().getProperties().get("monitortype");
if(obsMbean != null){
mgRuleConfig.getEventConfig().setPropertyValue("observedobject", obsMbean);
}
if(obsAttr != null){
mgRuleConfig.getEventConfig().setPropertyValue("observedattribute", obsAttr);
}
if(granularity != null){
mgRuleConfig.getEventConfig().setPropertyValue("granularityperiod", granularity);
}
if(monitorType.equals("countermonitor") || monitorType.equals("gaugemonitor")){
Boolean diffMode = (Boolean)handlerCtx.getInputValue("DiffMode");
if(diffMode != null){
mgRuleConfig.getEventConfig().setPropertyValue("differencemode", diffMode.toString());
}
String numType = (String)handlerCtx.getInputValue("NumType");
if(numType != null){
mgRuleConfig.getEventConfig().setPropertyValue("numbertype", numType);
}
if(monitorType.equals("countermonitor")){
String initThresh = (String)handlerCtx.getInputValue("InitThreshold");
String offset = (String)handlerCtx.getInputValue("Offset");
String modulus = (String)handlerCtx.getInputValue("Modulus");
if(initThresh != null){
mgRuleConfig.getEventConfig().setPropertyValue("initthreshold", initThresh);
}
if(offset != null){
mgRuleConfig.getEventConfig().setPropertyValue("offset", offset);
}
if(modulus != null){
mgRuleConfig.getEventConfig().setPropertyValue("modulus", modulus);
}
}
if(monitorType.equals("gaugemonitor")){
String lowThresh = (String)handlerCtx.getInputValue("LowThresh");
String highThresh = (String)handlerCtx.getInputValue("HighThresh");
if(lowThresh != null){
mgRuleConfig.getEventConfig().setPropertyValue("lowthreshold", lowThresh);
}
if(highThresh != null){
mgRuleConfig.getEventConfig().setPropertyValue("highthreshold", highThresh);
}
}
}
if(monitorType.equals("stringmonitor")){
String trigger = (String)handlerCtx.getInputValue("Trigger");
String valueProp = (String)handlerCtx.getInputValue("ValueProp");
if(trigger != null){
mgRuleConfig.getEventConfig().setPropertyValue("stringnotify", trigger);
}
if(valueProp != null){
mgRuleConfig.getEventConfig().setPropertyValue("stringtocompare", valueProp);
}
}
saveActionProperty(mgRuleConfig, handlerCtx);
}catch (Exception ex){
GuiUtil.handleException(handlerCtx, ex);