http://www.blogjava.net/alwayscy/archive/2006/12/06/85775.html 安装
http://xingxing5421.blog.163.com/blog/static/119446319201082534716623/ 排错
下载
进入
http://oss.oetiker.ch/rrdtool/pub/
下载最新的RRDTool
再进入
http://oss.oetiker.ch/rrdtool/pub/libs/
下载所需要库:
freetype-2.1.10.tar.bz2 04-May-2006 15:18 1.0M
libpng-1.2.10.tar.gz 04-May-2006 15:18 813K
libart_lgpl-2.3.17.tar.gz 04-May-2006 15:18 386K
zlib-1.2.3.tar.gz 18-Jul-2005 15:38 485K
设置目录
设置安装目录及编译目录:
BUILD_DIR=/tmp/rrdbuild
INSTALL_DIR=/usr/local/rrdtool-1.2.15
mkdir -p $BUILD_DIR
cd $BUILD_DIR
把下载的所有库放入这个目录
编译Zlib
tar zxf zlib-1.2.3.tar.gz
cd zlib-1.2.3
env CFLAGS="-O3 -fPIC" ./configure --prefix=$BUILD_DIR/lb
make
make install
编译LibPng
tar zxvf libpng-1.2.10.tar.gz
cd libpng-1.2.10
env CPPFLAGS="-I$BUILD_DIR/lb/include" LDFLAGS="-L$BUILD_DIR/lb/lib" CFLAGS="-O3 -fPIC" \
./configure --disable-shared --prefix=$BUILD_DIR/lb
make
make install
编译FreeType
tar jxvf freetype-2.1.10.tar.bz2
cd freetype-2.1.10
env CPPFLAGS="-I$BUILD_DIR/lb/include" LDFLAGS="-L$BUILD_DIR/lb/lib" CFLAGS="-O3 -fPIC" \
./configure --disable-shared --prefix=$BUILD_DIR/lb
make
make install
注意:此处解压是带"j"参数,因为是bz2包;其它是带"z"参数
编译libart_lgpl
tar zxvf libart_lgpl-2.3.17.tar.gz
cd libart_lgpl-2.3.17
env CFLAGS="-O3 -fPIC" ./configure --disable-shared --prefix=$BUILD_DIR/lb
make
make install
编译RRDTool
IR=-I$BUILD_DIR/lb/include
CPPFLAGS="$IR $IR/libart-2.0 $IR/freetype2 $IR/libpng"
LDFLAGS="-L$BUILD_DIR/lb/lib"
CFLAGS=-O3
export CPPFLAGS LDFLAGS CFLAGS
./configure --prefix=$INSTALL_DIR --disable-python --disable-tcl
make clean
make
make install
最后,可以将BIN目录加入PATH:
export PATH=/usr/local/rrdtool-1.2.15/bin:$PATH
使用要点
建库
rrdtool create test.rrd \
--start 920804400 \
DS:speed:COUNTER:600:U:U \
RRA:AVERAGE:0.5:1:24 \
RRA:AVERAGE:0.5:6:10
DS是数据源,默认是5分钟采一次,6:10表示,每隔5分钟采一次,共采6次计算一次平均值(即半小时),并留10次这样的平均值(保留5小时数据)
加入数据
rrdtool update test.rrd 920808300:12420
即以time:value对的方式向它添加
出图
rrdtool graph speed.png \
--start 920804400 --end 920808000 \
DEF:myspeed=test.rrd:speed:AVERAGE \
LINE2:myspeed#FF0000
LINE2表示用2象素的线来画,FF0000是红色
DEF是定义一个变量
计算后出图
rrdtool graph speed3.png \
--start 920804400 --end 920808000 \
--vertical-label km/h \
DEF:myspeed=test.rrd:speed:AVERAGE \
"CDEF:kmh=myspeed,3600,*" \
CDEF:fast=kmh,100,GT,kmh,0,IF \
CDEF:good=kmh,100,GT,0,kmh,IF \
HRULE:100#0000FF:"Maximum allowed" \
AREA:good#00FF00:"Good speed" \
AREA:fast#FF0000:"Too fast"
CDEF是计算变量
kmh=myspeed,3600,*表示,kmh是myspeed*3600,引号是为防止*被误解
kmh,100,GT,kmh,IF表示,((( kmh,100 ) GT ), 0, kmh) IF,也即判断是kmh大于100取0值,否则取值kmh
HRULE是画一条警戒线
DS种类
COUNTER - 持续增长值,RRD会前后相减再除时间计算平均值
GAUGE - 测量值,RRD不做处理,直接存
DERIVE - 变化值可以为负,其它与COUNTER一致
ABSOLUTE - 也是不改变其值,直接存(与GAUGE有何区别呢?)
最大值的WRAP
当到达最大值时,COUNTER会被RESET,导致前后两值相减为负,这不符合COUNTER的定义,所以它会尝试使用32位的最大值与这个负值相加来得到正常的正值,如果还是负,它会尝试用64位的最大值来使它变正。大部分情况可以处理。
以上内容主要参考如下网页:
http://oss.oetiker.ch/rrdtool/doc/rrdbuild.en.html
http://oss.oetiker.ch/rrdtool/tut/rrdtutorial.en.html
最近,在安装ddrtool,进行编译时,提示如下:
#./configure --prefix=/usr/local/ddrtool
configure: error: Please fix the library issues listed above and try again.
解决方法如下:
安装pango
yum -y install pango*
安装libart_lgpl-devel这个包
yum -y install libart_lgpl-devel
这样,安装完成后就可以继续了
config.status: creating po/Makefile
config.status: executing default commands
checking in... and out again
ordering CD from http://tobi.oetiker.ch/wish .... just kidding ;-)
----------------------------------------------------------------
Config is DONE!
With MMAP IO: yes
Build rrd_getopt: no
Static programs: no
Perl Modules: perl_piped perl_shared
Perl Binary: /usr/bin/perl
Perl Version: 5.8.8
Perl Options: PREFIX=/usr/local/rrdtool LIB=/usr/local/rrdtool/lib/perl/5.8.8
Ruby Modules: ruby
Ruby Binary: /usr/bin/ruby
Ruby Options: sitedir=/usr/local/rrdtool/lib/ruby
Build Lua Bindings: no
Build Tcl Bindings: no
Build Python Bindings: yes
Build rrdcgi: yes
Build librrd MT: yes
Use gettext: yes
With libDBI: no
Libraries: -lxml2 -lcairo -lcairo -lcairo -lm -lcairo -lpng12 -lglib-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0
Type 'make' to compile the software and use 'make install' to
install everything to: /usr/local/rrdtool.
... that wishlist is NO JOKE. If you find RRDtool useful
make me happy. Go to http://tobi.oetiker.ch/wish and
place an order.
-- Tobi Oetiker <[email protected]>
----------------------------------------------------------------
#make && make install
这样,ddrtool就安装完成了