Issue Fetching Report Data from /etc/reports/diskusage.html via Code
Hello All,
We are working on a project where we need to fetch the disk usage report from the following URL:
/etc/reports/diskusage.html
Once fetched, we need to share this report via email to clients on a daily basis.
We tried to achieve this by utilizing a service, scheduler, and JavaScript functionality. Below is the Java code we used to attempt fetching the data:
try (CloseableHttpResponse reportResponse = httpClient.execute(new HttpGet("http://localhost:4502/etc/reports/diskusage.html"))) {
if (reportResponse.getStatusLine().getStatusCode() == 200) {
String reportContent = EntityUtils.toString(reportResponse.getEntity());
Document doc = Jsoup.parse(reportContent);
Element restable = doc.getElementById("restable");
if (restable != null && !restable.text().isEmpty()) {
isReportGenerated = true;
String reportData = restable.html();
logger.info("Report content captured successfully.{}", reportData);
}
}
}
Issue:
- When we manually visit the URL in the browser, we are able to see the disk usage report.
- However, when accessing the page programmatically through our code, the restable element is fetched, but its content is empty.
Attempts Made:
- Added Thread.sleep in the backend to account for any delay.
- Tried using MutationObserver and window.onload in the frontend.
- Despite these attempts, we continue to get an empty restable content when trying to fetch it programmatically.
Has anyone faced a similar issue? Is there a specific way to handle the fetching of dynamic content like this via HTTP requests? Any guidance or suggestions would be greatly appreciated!Thanks in advance!