2012-03-22 60 views
3

我有一箇舊的RRD文件,只設置爲跟蹤1年的歷史。我決定更多的歷史會很好。我做了rrdtool調整大小,RRD現在變大了。我有這個RRD文件的舊備份,我想合併舊數據,以便最新的RRD也有歷史數據。合併多個RRD隨着時間的推移

我已經試過了RRD的contrib 「merged-rrd.py」,但它給出了:

$ python merged-rrd.py ../temperature-2010-12-06.rrd ../temperature-2011-05-24.rrd merged1.rrd 
    merging old:../temperature-2010-12-06.rrd to new:../temperature-2011-05-24.rrd. creating merged rrd: merged1.rrd 
    Traceback (most recent call last): 
     File "merged-rrd.py", line 149, in <module> 
      mergeRRD(old_path, new_path, mer_path) 
     File "merged-rrd.py", line 77, in mergeRRD 
      odict = getXmlDict(oxml) 
     File "merged-rrd.py", line 52, in getXmlDict 
      cf = line.split()[1] 
    IndexError: list index out of range 

也試過 「rrd_merger.pl」:

$ perl rrd_merger.pl --oldrrd=../temperature-2010-12-06.rrd --newrrd=../temperature-2011-05-24.rrd --mergedrrd=merged1.rrd 
    Dumping ../temperature-2010-12-06.rrd to XML: /tmp/temperature-2010-12-06.rrd_old_8615.xml 
    Dumping ../temperature-2011-05-24.rrd to XML: /tmp/temperature-2011-05-24.rrd_new_8615.xml 
    Parsing ../temperature-2010-12-06.rrd XML......parsing completed 
    Parsing ../temperature-2011-05-24.rrd XML... 
    Last Update: 1306217100 
    Start processing Round Robin DB 
    Can't call method "text" on an undefined value at rrd_merger.pl line 61. 
    at rrd_merger.pl line 286 
    at rrd_merger.pl line 286 

有沒有結合的工具或合併有用的RRD?

回答

0

尋找在由產生rrdtool的XML文件,則在Perl腳本一個簡單的邏輯錯誤。 AVERAGE元素足夠簡單,但標籤包含在內部文本標籤內。

  <cf> AVERAGE </cf> 
      <pdp_per_row> 1 </pdp_per_row> <!-- 300 seconds --> 

      <params> 
      <xff> 5.0000000000e-01 </xff> 
      </params> 

解析只是要進行調整了一下,在工作時,反饋這裏的修復(在這裏很容易爲「谷歌」),也到腳本的作者進行修復。

+0

我不知道的Perl,所以感謝您的分析,但修復仍然會在你挖,這裏指針可以理解的。 – hasienda 2012-04-06 12:36:38

2

這對我來說固定rrdtool-merge.pl:

<  my $xff   = $new_rra->first_child('xff')->text; 
--- 
>  my $xff   = $new_rra->first_child_text('xff'); 

從XML ::嫩枝文檔:

first_child_text ($optional_condition) 
    Return the text of the first child of the element, or the first child 
    matching the $optional_condition If there is no first_child then returns ''. This 
    avoids getting the child, checking for its existence then getting the text for trivial 
    cases. 
+0

它確實對我有用。 – 2013-04-30 13:28:34

1

的rrdmerge.pl工具,包含Routers2在/額外目錄,可以做到這一點。從http://www.steveshipway.org/software/rrd/

收集最新版本的路由器2這是我爲合併多個存檔的MRTG RRD文件而寫的一個實用程序,它聽起來與您提到的情況完全相同。

這對OP來說可能已經太晚了,但希望對後來來這裏的人有用。它可以合併任何RRD文件,即使使用不同的DS,RRA或時間間隔,也可以生成XML或RRD文件,並從組件RRD文件中選擇最佳可用數據以生成輸出。

例子:

rrdmerge.pl --rrd --libpath $RRDLIBDIR --output /tmp/merge.rrd --rows 12000 $FROMDIR/file.rrd $ARCHIVE/*.rrd 
相關問題