35 |
|
* Performs the service check on a given host. |
36 |
|
* |
37 |
|
* @param hostname the host to check |
38 |
+ |
* @return XML data representing the result of the test |
39 |
|
*/ |
40 |
|
public String runServiceCheck(String hostname){ |
41 |
|
String status = ""; |
48 |
|
connection.setRequestProperty("User-Agent", "i-scream HTTP Service Checker v" + REVISION.substring(11, REVISION.length() - 2)); |
49 |
|
// connect and do the request |
50 |
|
connection.connect(); |
51 |
< |
status += connection.getResponseCode(); |
51 |
> |
if (connection.getResponseCode() == 200 ) { |
52 |
> |
status = "0"; |
53 |
> |
} else { |
54 |
> |
status = "1"; |
55 |
> |
} |
56 |
|
message = connection.getResponseMessage(); |
57 |
|
connection.disconnect(); |
58 |
|
} catch (Exception e) { |
59 |
< |
status = "0"; |
59 |
> |
status = "1"; |
60 |
|
message = "Service check failed to establish connection to host:" + e.getMessage(); |
61 |
|
} |
62 |
|
// send the results back |