rrdDb의 간단한 설명
http://blog.daum.net/_blog/BlogTypeView.do?blogid=0niJy&articleno=24
자세한 설명
http://www.joinc.co.kr/w/Site/RRD
1) rrd4j 라이브러리 추가
2) 데이터 저장
String rrdFile = "/data/" + "1_1.rrd";
File file = new File(rrdFile);
START = Util.getTimestamp( c1.getTime())-1;
final int step = 60;
final int sampling = 5;
final int row = 8640;
RrdDef rrdDef = new RrdDef(rrdFile, step);
rrdDef.setStartTime(START);
rrdDef.addDatasource("response_time", DsType.GAUGE, step * 7, 0, Double.NaN);
rrdDef.addDatasource("speed", DsType.GAUGE, step * 7, 0, Double.NaN);
rrdDef.addArchive(ConsolFun.MAX, 0.5, sampling, row); // 1 step(sampling),
RrdDb rrdDb = null;
Sample sample = null;
try {
rrdDb = new RrdDb(rrdDef);
sample = rrdDb.createSample();
} catch (IOException e1) {
System.out.println("HomeController - IOException - create");
e1.printStackTrace();
}
for( info_DTO mi : list)
{
long ts = Util.getTimestamp(mi.test_time);
sample.setTime(ts);
sample.setValue("response_time", mi.response_time/1024*1024);
sample.setValue("speed", mi.speed);
try
{
sample.update();
}
catch (IOException e) {
System.out.println("HomeController - IOException - update");
e.printStackTrace();
}
}
try {
rrdDb.close();
} catch (IOException e) {
System.out.println("HomeController - IOException - close");
e.printStackTrace();
}
'Java Story' 카테고리의 다른 글
[ JAVA ] 이클립스 전체 검색 (0) | 2016.04.28 |
---|---|
[ JAVA ] tomcat javax.servlet.http 에러 해결 방법 (0) | 2016.04.11 |
[ JAVA ] [ RRD ] RrdDef (0) | 2016.04.04 |
[ JAVA ] [ Mybatis ] mapper 파일 등록 (단일/다수) (0) | 2016.04.01 |
[Spring] [Mybatis] Request processing failed; nested exception is java.lang.NullPointerException (0) | 2016.03.30 |
[JAVA] [CentOS] 이클립스 설치 (0) | 2016.03.24 |
[ JAVA ] [ Spring ] mybatis 라이브러리 이용해보기 (0) | 2016.03.22 |
[ Java ] Persisted Framework (0) | 2016.03.21 |