JRobin中rrd——xml和xml——rrd

import java.io.IOException;
import org.jrobin.core.RrdDb;
import org.jrobin.core.RrdDef;
import org.jrobin.core.RrdException;




public class testXML {


/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
testXML test = new testXML();
test.transXML("D://");
//test.fromRrd("D://");
}

// 根據XML文件獲取RrdDb  RrdDb rrdDb = new RrdDb("new.rrd" "old.xml"); 對應:rrdtool restore new.rrd old.xml
public void transXML(String rootPath){

        RrdDb rrdDb;
        
try {
//創建rrd

try {
rrdDb = new RrdDb(rootPath + "disk.rrd",rootPath  
       + "disk.xml");
System.out.println("[info:]" + rrdDb.getInfo() + "[path:]"  
               + rrdDb.getPath());  
       rrdDb.close();  
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
 
} catch (RrdException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}  
       
}

//根據rrd獲得xml 對應:rrdtool dump test.rrd > test.xml
public void fromRrd(String rootPath){
RrdDb rrdDb;
        
try {
rrdDb = new RrdDb(rootPath + "disk.rrd");
System.out.println("[info:]" + rrdDb.getInfo() + "[path:]"  
               + rrdDb.getPath());  
rrdDb.dumpXml(rootPath+"disk.xml");
       rrdDb.close();  
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RrdException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}  
       
}


}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章