我有几百个rrds,我想为所有这些rrds添加5个额外的数据源。
- Soln -
David OBrien在邮件列表中回复
搜索档案(你应该先做的)和谷歌搜索我发现有几个人使用这个......
用perl。安装RRD:简单
#!/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
或任何类型..
享受。
答案 0 :(得分:2)
使用rrddump和rrdrestore。
就这样:
rrdtool dump my.rrd > file.xml
./rrdAddDS.pl file.xml newDsName > new_file.xml
rrdtool restore new_file.xml my_new.rrd
你可以在这里参考:
http://osdir.com/ml/db.rrdtool.user/2003-08/msg00115.html
在这里: http://www.docum.org/drupal/sites/default/files/add_ds_to_rrd.pl_.txt
答案 1 :(得分: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 :(得分:1)
由于版本1.5 rrdtool create
可以"预填充"来自具有--source
选项的现有文件的数据。此功能无需额外脚本即可解决问题。