AlertDefinition d = new AlertDefinition();
AlertAction emailAlertAction = new AlertAction();
emailAlertAction.setClassName("com.hyperic.hq.bizapp.server.action.email.EmailAction");
AlertActionConfig alertActionConfigNotifyTypes = new AlertActionConfig();
alertActionConfigNotifyTypes.setKey("notifyType");
alertActionConfigNotifyTypes.setValue("users");
AlertActionConfig alertActionConfigNames = new AlertActionConfig();
alertActionConfigNotifyTypes.setKey("names");
alertActionConfigNotifyTypes.setValue("pippo");
emailAlertAction.getAlertActionConfig().add(alertActionConfigNotifyTypes);
emailAlertAction.getAlertActionConfig().add(alertActionConfigNames);
d.getAlertAction().add(emailAlertAction);
Unfortunately in Hyperic 4.5.3 this doesn't seem to work (see also https://jira.hyperic.com/browse/HQAPI-147)
The only way which seems to work in HQApi is by escalation:
<AlertDefinition mtime="1336305843209" ctime="1336305430467" id="10745" name="[Down]" description="[Down]" priority="2" enabled="true" active="true" frequency="0" count="0" range="0" willRecover="true" notifyFiltered="false" controlFiltered="false">
<Resource id="12473" name="/tmp/hyperictestdir"/>
<Escalation id="10001" name="ACME Project Team Escalation" description="" pauseAllowed="true" maxPauseTime="9223372036854775807" notifyAll="false" repeat="true"/>
<AlertCondition required="true" type="1" thresholdValue="0.0" thresholdComparator="=" thresholdMetric="Availability"/>
</AlertDefinition>
The escalation "ACME Project Team Escalation" must have been previously setup in Administration / Escalation Schemes Configuration
or with the org.hyperic.hq.hqapi1.EscalationApi.createEscalation() API
You can also retrieve existing escalations by name with EscalationApi.getEscalation(String name)
No comments:
Post a Comment