@Test
public void graphite() throws IOException {
int val1 = (getValue("http://graphite.kwangsiklee.com/render?target=lks.login.member.web.cnt&format=raw&from=-60min"));
System.out.println(val1);
}
@Test
public void graphite2() throws IOException {
int val1 = (getValue("http://graphite.kwangsiklee.com/render?target=lks.login.member.web.cnt&format=raw&from=1496119855"));
System.out.println(val1);
}
@Test
public void graphite3() throws IOException {
// 10분이내, json 단위
getValue("http://graphite.kwangsiklee.com/render?target=lks.login.member.web.cnt&format=json&from=1496120400&until=1496121000");
}
private void getValue(String url) throws IOException {
System.out.println("url = " + url);
HttpClient httpClient = HttpClientBuilder.create().build();
HttpGet get = new HttpGet(url);
HttpResponse response = httpClient.execute(get);
String body = EntityUtils.toString(response.getEntity());
String data = body.split("\\|")[1];
String[] dataArr = data.split(",");
List<Integer> valueList = new ArrayList<Integer>();
for (int i = 0; i < dataArr.length; i++) {
if (!"None".equals(dataArr[i].trim())) {
valueList.add(Integer.parseInt(dataArr[i].replace(".0", "").trim()));
}
}
for (int i = 0; i < valueList.size(); i++) {
System.out.println(valueList.get(i));
}
}