向现有RRD添加新数据源

8
我有几百个rrd文件,我想为所有这些rrd文件添加5个额外的数据源。
  1. 这样做是否明智?
  2. 最好和最快的方法是什么?
-- 解决方案 -- David OBrien在邮件列表中回复说: 在搜索档案(你应该先这样做)和谷歌搜索之后,我发现有好几个人使用这种方法......
用Perl。安装RRD:Simple。
#!/usr/local/bin/perl 

use strict; 
use RRD::Simple (); 

my $rrd = RRD::Simple->new(); 
my $rrdfile=$ARGV[0]; 
my $source=$ARGV[1]; 
my $type=$ARGV[2]; 
chomp($type); 
$rrd->add_source($rrdfile, $source => $type); 

用法:

./addSource.pl file.rrd ds GAUGE 

无论类型是什么,都可以使用此方法。祝您使用愉快。

你应该把David的解决方案作为答案添加到你自己的问题中并接受它。 - umläute
3个回答

2

如果您正在使用PNP4Nagios (https://docs.pnp4nagios.org/pnp-0.6/start),他们提供了一个实用脚本rrd_modify.pl来修改现有的RRD数据文件。

    $ rrd_modify.pl -h

   === rrd_modify.pl 0.01 ===
   Copyright (c) 2012 PNP4Nagios Developer Team (http://www.pnp4nagios.org)

   This script can be used to alter the number of data sources of an RRD file.

   Usage:
   rrd_modify.pl RRD_file insert|delete start_ds[,no_of_cols] [type]

   Arguments:
   RRD_file
      the location of the RRD file. It will NOT be overwritten but appended
      by ".chg"
   insert or delete
      the operation to be executed
   start_ds
      the position at which the operation starts (1..no of data sources+1)
   no_of_cols
      (an optional) number of columns which will be added/deleted
   type
      the data type (one of GAUGE, COUNTER)
                Defaults to GAUGE if not specified for insert operations
        (DERIVE, ABSOLUTE, COMPUTE have not been tested and might result in
                 errors during creation of a new RRD file)

2

2
自1.5版本以来,rrdtool create 可以使用 --source 选项从现有文件中“预填充”数据。这个功能解决了问题,无需额外的脚本。
另请参见下面的 Matija Nalis 的评论。

3
更简单的方法是,您可以使用 rrdtool tune my.rrd DS:ds_name:GAUGE:900:-50:100 来向现有的 .rrd 文件添加数据源,同时保留旧的结构和数据。 - Matija Nalis

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接