Using a Custom Alert Processing Class
FeaturedUsing a Custom Alert Processing Class
You can write a Java class which will be invoked for each alert created by Applicare agents by implementing the interface com.arcturus.alerts.notifications.AlertAction and the only method in it, public void processAlert(AlertQueue alert).
You can get the details of the alert using the getter methods of the AlertQueue object as shown in the example class below:
package com.arcturus.alerts.notifications;
import java.text.SimpleDateFormat;
import com.arcturus.alerts.domain.AlertQueue;
public class SampleAction implements com.arcturus.alerts.notifications.AlertAction{
public void processAlert(AlertQueue alert) {
System.out.println("Server: " + alert.getServer()); //the server name where the alert was generated
System.out.println("Type: " + alert.getSubsystem()); //type of the alert (JMX_ALERT, PLATFORM_ALERT, etc..)
System.out.println("Priority: " + alert.getPriority()); //priority of the alert
System.out.println("Message: " + alert.getMessage()); //user defined message in alert definition (description)
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println("Created: " + dateFormat.format(alert.getCreated())); //time the alert was created
}
}
To deploy the class and any dependent classes, you can package it in a .jar file and copy to the Applicare/server/ext folder (if the folder doesn't exist, create it). Then restart the Applicare server.
Note: When compiling you will have to include the Applicare/server/webapps/applicare/WEB-INF/classes folder in your classpath.
Once the server restarts, go to Applicare > Configuration > Advanced Options and provide the fully qualified class name of your custom class in the Custom Alert Processing Class field and click Apply.
This should allow execution of custom alert by executing the processAlert() method.
Please refer to the attached sampleActionTest.jar file.
Please sign in to leave a comment.
Comments
0 comments