
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, {
// Specify the file path for saving the analysis reports
File path = new File("/<report folder>/HANADumpAnalyzer/");
JSONArray jsonArray = new JSONArray ();
// Get all the analysis reports under the report folder
File [] files = path.listFiles();
Arrays.sort(files, new Comparator<File>(){
public int compare(File f1, File f2) {
return Long.valueOf(f2.lastModified()).compareTo(f1.lastModified());
}
});
// Get the key information (e.g. URLs, Runtime dump time) for the analysis reports, Saving the list of analysis reports to a JSONArray
for (File file : files){
if (file.isDirectory()) {
File indexFile = new File (file.getAbsolutePath() + "/analysis.html");
if (indexFile.exists()) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("Link", "http://<tomcat server:8080>/reports/HANADumpAnalyzer/"
+ file.getName() + "/analysis.html");
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(
new FileInputStream(new File(file.getAbsolutePath() + "/analysis.html"))));
String s;
while ((s = br.readLine()) != null) {
if (s.contains("Runtime dump time:")) {
int index = s.indexOf("Runtime dump time:");
jsonObject.put("CreationTime", s.substring(index + "Runtime dump time: ".length(), index
+ "Runtime dump time: ".length() + "2017-06-02 13:59:28 472 Local".length()));
} else if (s.contains("<tr><th>Host</th><td>")) {
jsonObject.put("ServerName", s.substring("<tr><th>Host</th><td>".length(), s.length() - "</td></tr>".length()));
}
}
} catch (IOException e) {
// Add suitable error handling
} finally {
try {
br.close();
} catch (IOException e) {
// Add suitable error handling
}
}
jsonObject.put("Reason", "Runtimedump");
jsonArray.add(jsonObject);
}
}
}
// Respond the JSONArray(i.e. list of analysis reports) back
response.setContentType("application/json");
PrintWriter out = response.getWriter();
out.println(jsonArray.toString());
out.flush();
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
HTTP://<servername:port>/manager/html
module.exports = (robot) ->
robot.respond /show error history/i, (response) ->
runtimedumps = "\n"
robot.http("http://<tomcat server:8080>/HdaBot
/GetRuntimedumpsServlet").header('Accept',
'application/json').get() (err, res, body) ->
data = JSON.parse body
for k,v of data
runtimedumps = runtimedumps + v.CreationTime + ", " + v.ServerName + ", "
+ v.Reason + ", <" + v.Link + "|Analyze>\n"
response.reply runtimedumps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
14 | |
13 | |
12 | |
11 | |
10 | |
9 | |
8 | |
8 | |
8 | |
7 |