16
16
import com .fasterxml .jackson .databind .ObjectMapper ;
17
17
import com .newrelic .metrics .publish .Agent ;
18
18
import com .newrelic .metrics .publish .configuration .ConfigurationException ;
19
- import com .newrelic .metrics .publish .processors .EpochProcessor ;
20
- import com .newrelic .metrics .publish .processors .Processor ;
21
19
import com .newrelic .metrics .publish .util .Logger ;
22
20
23
21
/**
@@ -31,11 +29,10 @@ public class MonitoringAgent extends Agent {
31
29
private static final String VERSION = "1.0.0" ;
32
30
33
31
private static final String HTTP = "http" ;
34
- private static final String ATG_INSTANCE_URL = "/oe-diagnostics/rest/api/metrics/get" ;
32
+ private static final String ATG_METRICS_URI = "/oe-diagnostics/rest/api/metrics/get" ;
35
33
36
34
private String name ;
37
35
private URL url ;
38
- private Processor repositoryCreationRate ;
39
36
40
37
private static Logger LOGGER = Logger .getLogger (MonitoringAgent .class );
41
38
@@ -50,8 +47,7 @@ public MonitoringAgent(String name, String host, int port) throws ConfigurationE
50
47
super (GUID , VERSION );
51
48
try {
52
49
this .name = name ;
53
- this .url = new URL (HTTP ,host ,port , ATG_INSTANCE_URL );
54
- this .repositoryCreationRate = new EpochProcessor ();
50
+ this .url = new URL (HTTP ,host ,port , ATG_METRICS_URI );
55
51
} catch (MalformedURLException e ) {
56
52
throw new ConfigurationException ("ATG Statistics Engine metric URL could not be parsed" , e );
57
53
}
@@ -61,8 +57,7 @@ public MonitoringAgent(String name, String host) throws ConfigurationException {
61
57
super (GUID , VERSION );
62
58
try {
63
59
this .name = name ;
64
- this .url = new URL (HTTP ,host , ATG_INSTANCE_URL );
65
- this .repositoryCreationRate = new EpochProcessor ();
60
+ this .url = new URL (HTTP ,host , ATG_METRICS_URI );
66
61
} catch (MalformedURLException e ) {
67
62
throw new ConfigurationException ("ATG Statistics Engine metric URL could not be parsed" , e );
68
63
}
@@ -128,7 +123,7 @@ public String handleResponse(
128
123
return httpclient .execute (httpget , responseHandler );
129
124
130
125
} catch (ClientProtocolException e ) {
131
- e .printStackTrace ();
126
+ e .getMessage ();
132
127
} catch (IOException e ) {
133
128
e .printStackTrace ();
134
129
} finally {
@@ -150,29 +145,4 @@ private static String getURLString(URL url) {
150
145
return urlStr .toString ();
151
146
}
152
147
153
-
154
- /*private JSONObject getJSONResponse() {
155
- Object response = null;
156
- InputStream inputStream = null;
157
- HttpURLConnection connection = null;
158
- try {
159
- connection = (HttpURLConnection) url.openConnection();
160
- connection.addRequestProperty("Accept", "application/json");
161
- inputStream = connection.getInputStream();
162
- response = JSONValue.parse(new InputStreamReader(inputStream));
163
- } catch (IOException e) {
164
- System.out.println("Error: Unable to access to agent at "+url.getHost()+":"+url.getPort());
165
- } finally {
166
- if (inputStream != null) {
167
- try {
168
- inputStream.close();
169
- } catch (IOException e) {}
170
- }
171
- if (connection != null) {
172
- connection.disconnect();
173
- }
174
- }
175
- return (JSONObject) response;
176
- }*/
177
-
178
148
}
0 commit comments