We have a need to check if a custom error page is correctly in place for certain servers based on Tomcat. Unfortunately, the HTTP Advanced sensor doesn't seem to get past (ignore) the 404 error and scrape the error page itself for text I'm looking for. I'm guessing the sensor will only parse for text if the page returns a 200.
Background - Security compliance scans will complain if the default Tomcat error page is used.
Is there a solution for this?
Thanks!
Article Comments
Thanks for the reply, but no, we aren't monitoring for status codes. We need to scrape the text of the 404 error page, to make sure the default Tomcat error page isn't being used.
We ended up developing a Powershell script to handle this.
try { Invoke-WebRequest https://www.contoso.com/123 } catch { $result = $_.Exception.Response.GetResponseStream() $reader = New-Object System.IO.StreamReader($result) $reader.BaseStream.Position = 0 $reader.DiscardBufferedData() $responseBody = $reader.ReadToEnd(); $responseBody.Contains(“Tomcat”) }
May, 2020 - Permalink
Hi Peter,
I'm afraid this is indeed only possible using a powershell script and custom sensor. The default HTTP sensors cannot be used here. Thank you for sharing your script here!
Jun, 2020 - Permalink
Hi Peter,
You're right here, this article lists all status codes and how the PRTG sensors behave. Do I understand you correctly that you simply want to monitor for status codes? Then, this would help.
Kind regards,
Felix Saure, Tech Support Team
May, 2020 - Permalink