1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.appstatus.demo.check;
17
18 import java.net.InetAddress;
19
20 import net.sf.appstatus.core.check.AbstractCheck;
21 import net.sf.appstatus.core.check.ICheckResult;
22
23 public class GooglePingStatusChecker extends AbstractCheck {
24
25 public ICheckResult checkStatus() {
26 ICheckResult result = null;
27
28 try {
29 InetAddress address = InetAddress.getByName("www.google.com");
30
31 if (address.isReachable(2000)) {
32 result = createResult(OK);
33 result.setDescription("Google Access ok");
34
35 } else {
36 throw new Exception("Ping timeout (2000ms)");
37 }
38
39 } catch (Exception e) {
40 result = createResult(WARN);
41 result.setDescription("Google ping failed");
42 result.setResolutionSteps("Ping failed. This means that ICMP messages are blocked by this host. (This may not be an issue) "
43 + e.getMessage());
44
45 }
46
47 return result;
48 }
49
50 public String getGroup() {
51 return "google";
52 }
53
54 public String getName() {
55 return "Google Ping check";
56 }
57
58 }