Customer wants to make a plug-in which is taken agent names from incidents on DT.
There is usually shown agent name from incidents, here they tried to get it though Plug-In, however, they could not get agent names even though they could get some messages through Plug-In from incidents.
If they want make a Plug-in which is able to get agent names from incidents defined, how they can get agent names from incidents ?
they expect to have 20 incidents to be defined for 56 JVMs and 14 web servers
Below is their source ;
public Status execute(ActionEnvironment env) throws Exception {
Status status = new Status();
LogFileWriter writer;
if(isSMB) {
writer = new LogFileWriter(folder, fileName, user_name, password);
}else {
writer = new LogFileWriter(folder, fileName);
}
Collection<Incident> incidents = env.getIncidents();
for (Incident incident : incidents) {
String message = incident.getMessage();
String time = incident.getStartTime().toString();
String profileStr = incident.getKey().toString();
String matcher = "systemProfile=";
int firstInt = profileStr.indexOf(matcher);
int endInt = profileStr.indexOf("]");
String proFile;
proFile = profileStr.substring(firstInt + matcher.length(),endInt);
status = writer.writeLog(message, changeFormat(time), log1, proFile, incidentLevel.substring(0, 1));
log.log(Level.INFO, "Host = " + env.getHost());
log.log(Level.INFO, "System Profile = " + env.getSystemProfileName());
log.log(Level.INFO, "Message = " + message);
log.log(Level.INFO, "Start Time = " + time);
log.log(Level.INFO, "Profile = " + proFile);
Collection<PurePath> purepaths = incident.getPurePaths();
for(PurePath purePath : purepaths) {
log.log(Level.INFO, "Agent ID = " + purePath.getAgentId());
}
}
return status;
}
Answer by Eugene T. ·
Hi Sanghyun,
The com.dynatrace.diagnostics.pdk.Incident interface contains Collection of violations referenced by the Incident.getViolations() method. Each com.dynatrace.diagnostics.pdk.Violation, i.e. each object which implements the com.dynatrace.diagnostics.pdk.Violation, contains reference to the com.dynatrace.diagnostics.pdk.Source of violation. Object which implements the com.dynatrace.diagnostics.pdk.Source interface can be one of the following 5 types:
The com.dynatrace.diagnostics.pdk.AgentSource.getName() method returns name of the agent which is a source of the violation that triggered incident.
Please let me know if you have any further questions.
Eugene.
JANUARY 15, 3:00 PM GMT / 10:00 AM ET