String statusCode = statusUrlEntry.getKey();
String statusUrl = statusUrlEntry.getValue();
TopicusServerStatus server = new TopicusServerStatus(statusCode,
statusUrl);
status.addServer(server);
Alert oldAlert = oldAlerts.get(statusUrl);
try {
StatusPageResponse statuspage = getStatuspage(statusUrl);
if (!statuspage.isOk()) {
server.setServerStatus(DotColor.RED);
Alert alert = new Alert(oldAlert, DotColor.RED, project,
"Server " + statusCode + " offline with HTTP code "
+ statuspage.getHttpStatusCode());
oldAlerts.put(statusUrl, alert);
alerts.add(alert);
continue;
}
String page = statuspage.getPageContent();
Source source = new Source(page);
source.fullSequentialParse();
List<Element> tableHeaders = source
.getAllElements(HTMLElementName.TH);
for (Element tableHeader : tableHeaders) {
String contents = tableHeader.getContent().toString();
if ("Applicatie".equals(contents)) {
fetchApplicationVersion(server, tableHeader);
} else if ("Sessions/Requests".equals(contents)) {
fetchSessionAndRequestData(server, tableHeader);
} else if ("Wicket Sessions/Requests".equals(contents)) {
fetchSessionAndRequestData(server, tableHeader);
} else if ("Sessies/Requests".equals(contents)) {
fetchSessionAndRequestData(server, tableHeader);
} else if ("Wicket Sessies/Requests".equals(contents)) {
fetchSessionAndRequestData(server, tableHeader);
}
}
List<Element> tdHeaders = source
.getAllElements(HTMLElementName.TD);
for (Element td : tdHeaders) {
String contents = td.getContent().toString();
if ("Starttijd".equals(contents)) {
getStartTime(server, td);
}
}
server.setServerStatus(DotColor.GREEN);
oldAlerts.put(statusUrl, null);
} catch (Exception e) {
server.setServerStatus(DotColor.YELLOW);
Alert alert = new Alert(oldAlert, DotColor.YELLOW, project,
e.getMessage());
oldAlerts.put(statusUrl, alert);
alerts.add(alert);
log.warn("Could not retrieve status for '" + statusUrl + "': "
+ e.getClass().getSimpleName() + " - "