Anyone know any? I need to send in a http request and make sure the http response i got back is not http 500
views:
158answers:
5But, he's not unit testing. He clearly says that he's monitoring here. Why wouldn't you use a monitoring tool like Big Sister, Hyperic, Monit, etc.?
John Munsch
2009-03-03 13:36:43
+2
A:
I believe Hyperic HQ meets all of your criteria. It is open source, I believe it is written at least partially in Java, and it is designed to do all kinds of server monitoring.
It should be able to handle not only the kind of monitoring you requested but other necessary monitoring like memory, CPU usage, and disk space on your servers as well.
John Munsch
2009-03-02 05:41:51
A:
If you want to do this yourself, Apache HttpClient is an option:
GetMethod get = new GetMethod("http://www.stackoverflow.com");
try
{
int resultCode = client.executeMethod(get);
if (resultCode == 500)
{
//do something meaningful here
} // if
} // try
catch (Exception e)
{
e.printStackTrace();
}
finally
{
get.releaseConnection();
}
jt
2009-05-08 16:52:53
A:
While you find it you can use this:
import java.net.HttpURLConnection;
import java.net.URL;
import java.io.IOException;
public class SimplisticMonitor {
public static void main( String [] args ) throws IOException {
HttpURLConnection c = ( HttpURLConnection )
new URL( "http://stackoverflow.com" ).openConnection();
System.out.println( c.getResponseCode() );
}
}
OscarRyz
2009-05-08 17:28:49