├── po ├── LINGUAS ├── POTFILES.in ├── ChangeLog └── Makevars ├── doc ├── RRDp.pod ├── RRDs.pod ├── rrdruby.pod ├── rrdtutorial.es.pod ├── name.inc ├── rrdfirst.pod ├── rrdrestore.pod ├── rrdtool-xport.dtd ├── rrdtool-dump.dtd ├── rrdlast.pod ├── rrdlastupdate.pod ├── rrdresize.pod ├── rrdflushcached.pod ├── rrdpython.pod ├── rrdinfo.pod ├── rrddump.pod ├── Makefile.am └── rrdthreads.pod ├── bindings ├── python │ ├── AUTHORS │ ├── ACKNOWLEDGEMENT │ ├── README │ └── setup.py ├── perl-piped │ ├── MANIFEST │ ├── README │ ├── Makefile.PL │ ├── leaktest.pl │ ├── rrdpl.dsw │ ├── t │ │ └── base.t │ └── rrdpl.dsp ├── ruby │ ├── CHANGES │ ├── extconf.rb │ ├── README │ └── test.rb ├── dotnet │ ├── favicon.ico │ ├── rrdlib.sln │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── dnrrdlib.csproj │ └── dnrrd_binding_test.csproj ├── perl-shared │ ├── MANIFEST │ ├── README │ ├── RRDs.ppd │ ├── ntmake-build │ ├── Makefile.PL │ └── RRDs.pm ├── lua │ ├── compat-5.1r5 │ │ ├── compat-5.1.c │ │ ├── compat-5.1.h │ │ └── compat-5.1.lua │ ├── Makefile.am │ ├── README │ └── test.lua.bottom ├── tcl │ ├── ifOctets.tcl.in │ ├── README │ └── Makefile.am └── Makefile.am ├── NEWS ├── CHANGES ├── CONTRIBUTORS ├── favicon.ico ├── 00README ├── src ├── rrd_parsetime.h ├── librrd.pc.in ├── unused.h ├── strftime.h ├── rrd_version.c ├── rrd_i18n.h ├── rrd_nan_inf.c ├── rrd_is_thread_safe.h ├── rrd_xport.h ├── librrd.sym.in.in ├── plbasename.h ├── rrdupdate.c ├── rrd_hw_update.h ├── rrd_not_thread_safe.c ├── get_ver.awk ├── rrd_datalang.c ├── win32comp.c ├── pngsize.c ├── rrd_hw.h ├── rrd_last.c ├── rrd_first.c ├── rrd_rpncalc.h ├── rrd_tool.h ├── fnv.h ├── rrd_client.h ├── rrd_flushcached.c ├── rrd_thread_safe.c ├── Makefile.am ├── rrd_diff.c ├── rrd_hw_math.h ├── rrd_error.c ├── rrd_hw_math.c ├── rrd_thread_safe_nt.c ├── rrd_format.c └── hash_32.c ├── debian └── README ├── autogen.sh ├── etc ├── rrdcached-default └── rrdcached-init ├── examples ├── rrdcached │ ├── Makefile.am │ ├── RRDCached.pm │ └── rrdcached-size.pl ├── Makefile.am ├── cgi-demo.cgi.in ├── minmax.pl.in ├── bigtops.pl.in ├── stripes.pl.in ├── 4charts.pl.in └── piped-demo.pl.in ├── TODO ├── win32 ├── rrdtool.dsw ├── config.h ├── rrd_config.h.msvc ├── rrd.sln └── rrdtool.dsp ├── MakeMakefile ├── rrdtool-1.2-release ├── rrdtool-1.4-release ├── Makefile.am ├── .indent.pro ├── THREADS ├── README └── COPYRIGHT /po/LINGUAS: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /doc/RRDp.pod: -------------------------------------------------------------------------------- 1 | ../bindings/perl-piped/RRDp.pm -------------------------------------------------------------------------------- /doc/RRDs.pod: -------------------------------------------------------------------------------- 1 | ../bindings/perl-shared/RRDs.pm -------------------------------------------------------------------------------- /po/POTFILES.in: -------------------------------------------------------------------------------- 1 | src/rrd_getopt.c 2 | src/rrd_tool.c 3 | -------------------------------------------------------------------------------- /bindings/python/AUTHORS: -------------------------------------------------------------------------------- 1 | Hye-Shik Chang 2 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/rrdtool/master/NEWS -------------------------------------------------------------------------------- /CHANGES: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/rrdtool/master/CHANGES -------------------------------------------------------------------------------- /CONTRIBUTORS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/rrdtool/master/CONTRIBUTORS -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/rrdtool/master/favicon.ico -------------------------------------------------------------------------------- /doc/rrdruby.pod: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/rrdtool/master/doc/rrdruby.pod -------------------------------------------------------------------------------- /bindings/perl-piped/MANIFEST: -------------------------------------------------------------------------------- 1 | MANIFEST 2 | README 3 | Makefile.PL 4 | RRDp.pm 5 | t/base.t 6 | -------------------------------------------------------------------------------- /bindings/ruby/CHANGES: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/rrdtool/master/bindings/ruby/CHANGES -------------------------------------------------------------------------------- /doc/rrdtutorial.es.pod: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/rrdtool/master/doc/rrdtutorial.es.pod -------------------------------------------------------------------------------- /bindings/dotnet/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/rrdtool/master/bindings/dotnet/favicon.ico -------------------------------------------------------------------------------- /bindings/perl-shared/MANIFEST: -------------------------------------------------------------------------------- 1 | ntmake-build 2 | MANIFEST 3 | README 4 | Makefile.PL 5 | RRDs.pm 6 | RRDs.xs 7 | t/base.t 8 | -------------------------------------------------------------------------------- /bindings/lua/compat-5.1r5/compat-5.1.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/rrdtool/master/bindings/lua/compat-5.1r5/compat-5.1.c -------------------------------------------------------------------------------- /bindings/lua/compat-5.1r5/compat-5.1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/rrdtool/master/bindings/lua/compat-5.1r5/compat-5.1.h -------------------------------------------------------------------------------- /bindings/lua/compat-5.1r5/compat-5.1.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/rrdtool/master/bindings/lua/compat-5.1r5/compat-5.1.lua -------------------------------------------------------------------------------- /00README: -------------------------------------------------------------------------------- 1 | Title: RRDtool 2 | Date: 2010-03-22 3 | Owner: Tobias Oetiker 4 | Group: Software 5 | 6 | Round Robin Database Tool 7 | -------------------------------------------------------------------------------- /src/rrd_parsetime.h: -------------------------------------------------------------------------------- 1 | #ifndef __PARSETIME_H__ 2 | #define __PARSETIME_H__ 3 | 4 | #include 5 | 6 | #include "rrd.h" 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /bindings/perl-piped/README: -------------------------------------------------------------------------------- 1 | This is a Perl module for using RRDtool process via a set of pipes. 2 | 3 | perl Makefile.PL 4 | make test 5 | make install 6 | -------------------------------------------------------------------------------- /debian/README: -------------------------------------------------------------------------------- 1 | Find the latest debian packaging files at 2 | git://git.snow-crash.org/pkg-rrdtool.git and mirrored at 3 | git://git.tokkee.org/pkg-rrdtool.git 4 | -------------------------------------------------------------------------------- /bindings/python/ACKNOWLEDGEMENT: -------------------------------------------------------------------------------- 1 | ACKNOWLEDGMENT 2 | ============== 3 | 4 | This is a list of people who have made contributions to py-rrdtool. 5 | 6 | Matthew W. Samsonoff 7 | Brian E. Gallew 8 | -------------------------------------------------------------------------------- /doc/name.inc: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | =cut 4 | 5 | WARNING: DO NOT EDIT THE POD FILES. THEY ARE AUTO-GENERATED 6 | 7 | =pod 8 | 9 | rrdtool graph - Round Robin Database tool grapher functions 10 | 11 | Documentation for version 1.2.0 12 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # On MAC OS X, GNU libtoolize is named 'glibtoolize': 4 | if [ `(uname -s) 2>/dev/null` == 'Darwin' ] 5 | then 6 | glibtoolize 7 | else 8 | libtoolize 9 | fi 10 | 11 | autoreconf --force --install --verbose -I m4 12 | -------------------------------------------------------------------------------- /etc/rrdcached-default: -------------------------------------------------------------------------------- 1 | 2 | RUN_RRDCACHED=0 3 | 4 | RRDCACHED_USER="rrdcached" 5 | 6 | OPTS="-w 300 -z 300" 7 | 8 | PIDFILE="/var/run/rrdcached/rrdcached.pid" 9 | 10 | SOCKFILE="/var/run/rrdcached/rrdcached.sock" 11 | 12 | SOCKPERMS=0660 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/librrd.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: librrd 7 | Description: Library for the RRDtool 8 | Version: @PACKAGE_VERSION@ 9 | Libs: -L${libdir} -lrrd 10 | Cflags: -I${includedir} 11 | -------------------------------------------------------------------------------- /bindings/perl-shared/README: -------------------------------------------------------------------------------- 1 | These are the Perl bindings for rrdtool as a shared library. To compile do 2 | the following: 3 | 4 | perl Makefile.PL 5 | make test 6 | 7 | (win32 users try perl ntmake.pl) 8 | 9 | * if dynamic linking does not work, try 10 | 11 | perl Makefile.PL LINKTYPE=static 12 | make test 13 | -------------------------------------------------------------------------------- /examples/rrdcached/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | #AUTOMAKE_OPTIONS = foreign 4 | 5 | #ACLOCAL_M4 = $(top_srcdir)/config/aclocal.m4 6 | 7 | examplesdir = $(pkgdatadir)/examples/rrdcached 8 | examples_SCRIPTS = RRDCached.pm rrdcached-size.pl 9 | 10 | EXTRA_DIST = RRDCached.pm rrdcached-size.pl 11 | -------------------------------------------------------------------------------- /bindings/perl-piped/Makefile.PL: -------------------------------------------------------------------------------- 1 | use ExtUtils::MakeMaker; 2 | 3 | # See lib/ExtUtils/MakeMaker.pm for details of how to influence 4 | # the contents of the Makefile that is written. 5 | WriteMakefile( 6 | 'NAME' => 'RRDp', 7 | 'VERSION' => '0.99.0', # finds $VERSION 8 | 'linkext' => {LINKTYPE => ''}, 9 | 'dist' => {COMPRESS=>'gzip', SUFFIX=>'gz'}, 10 | ); 11 | -------------------------------------------------------------------------------- /bindings/perl-shared/RRDs.ppd: -------------------------------------------------------------------------------- 1 | 2 | RRDs 3 | Round Robin Database Tool 4 | Tobias Oetiker (tobi@oetiker.ch) 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /bindings/perl-piped/leaktest.pl: -------------------------------------------------------------------------------- 1 | #!/bin/perl -w 2 | $ENV{PATH}="/usr/ucb"; 3 | use strict; 4 | use RRDp; 5 | my $rrdfile='/tmp/test.rrd'; 6 | RRDp::start '/home/oetiker/data/projects/AABN-rrdtool/src/rrdtool'; 7 | print grep /rrdtool/,`ps au`; 8 | print grep /rrdtool/,`ps au`; 9 | my $i=0; 10 | while ($i<1000) { 11 | RRDp::cmd 'info /tmp/test.rrd'; 12 | $_ = RRDp::read; 13 | $i++; 14 | } 15 | $_ = RRDp::end; 16 | print grep /rrdtool/,`ps au`; 17 | -------------------------------------------------------------------------------- /src/unused.h: -------------------------------------------------------------------------------- 1 | /* define a macro to wrap variables that would 2 | otherwise generate UNUSED variable warnings 3 | Note that GCC's attribute unused only supresses the warning, so 4 | it is perfectly safe to declare something unused although it is not. 5 | */ 6 | 7 | #ifdef UNUSED 8 | #elif defined(__GNUC__) 9 | # define UNUSED(x) x __attribute__((unused)) 10 | #elif defined(__LCLINT__) 11 | # define UNUSED(x) /*@unused@*/ x 12 | #else 13 | # define UNUSED(x) x 14 | #endif 15 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | Random Feature Ideas for RRDtool 2 | -------------------------------- 3 | $Id$ 4 | 5 | make it possible to define order of legend items independant of their order 6 | on the commandline ... 7 | 8 | architecture independant storage format. 9 | 10 | micro second precision 11 | 12 | 2036 stable time 13 | 14 | add configurable counter wrap 15 | 16 | align data points not to GMT but some free offset 17 | 18 | allow starting through symlinks called rrdcreate rrdtune and the like 19 | -------------------------------------------------------------------------------- /po/ChangeLog: -------------------------------------------------------------------------------- 1 | 2009-05-26 gettextize 2 | 3 | * Makefile.in.in: New file, from gettext-0.17. 4 | * Rules-quot: New file, from gettext-0.17. 5 | * boldquot.sed: New file, from gettext-0.17. 6 | * en@boldquot.header: New file, from gettext-0.17. 7 | * en@quot.header: New file, from gettext-0.17. 8 | * insert-header.sin: New file, from gettext-0.17. 9 | * quot.sed: New file, from gettext-0.17. 10 | * remove-potcdate.sin: New file, from gettext-0.17. 11 | * POTFILES.in: New file. 12 | 13 | -------------------------------------------------------------------------------- /bindings/ruby/extconf.rb: -------------------------------------------------------------------------------- 1 | # $Id: extconf.rb,v 1.2 2001/11/28 18:30:16 miles Exp $ 2 | # Lost ticket pays maximum rate. 3 | 4 | require 'mkmf' 5 | 6 | if /linux/ =~ RUBY_PLATFORM 7 | $LDFLAGS += ' -Wl,--rpath -Wl,$(EPREFIX)/lib' 8 | elsif /solaris/ =~ RUBY_PLATFORM 9 | $LDFLAGS += ' -R$(EPREFIX)/lib' 10 | elsif /hpux/ =~ RUBY_PLATFORM 11 | $LDFLAGS += ' +b$(EPREFIX)/lib' 12 | elsif /aix/ =~ RUBY_PLATFORM 13 | $LDFLAGS += ' -Wl,-blibpath:$(EPREFIX)/lib' 14 | end 15 | 16 | dir_config("rrd","../../src","../../src/.libs") 17 | have_library("rrd", "rrd_create") 18 | create_makefile("RRD") 19 | -------------------------------------------------------------------------------- /examples/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | #AUTOMAKE_OPTIONS = foreign 4 | 5 | #ACLOCAL_M4 = $(top_srcdir)/config/aclocal.m4 6 | 7 | SUBDIRS = rrdcached 8 | 9 | EXTRA_DIST = cgi-demo.cgi.in 10 | 11 | examplesdir = $(pkgdatadir)/examples 12 | examples_SCRIPTS = cgi-demo.cgi piped-demo.pl shared-demo.pl \ 13 | stripes.pl bigtops.pl minmax.pl 4charts.pl perftest.pl 14 | 15 | cgi-demo.cgi: @srcdir@/cgi-demo.cgi.in $(top_builddir)/config.status 16 | sed 's,@''exec_prefix@,$(exec_prefix),' @srcdir@/cgi-demo.cgi.in > $@ 17 | chmod a+x $@ 18 | 19 | -------------------------------------------------------------------------------- /src/strftime.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** STRFTIME.H - For older compilers which lack strftime() 3 | ** 4 | ** Note: To avoid name collision with newer compilers, the function name 5 | ** strftime_() is used. 6 | */ 7 | 8 | #ifndef STRFTIME__H 9 | #define STRFTIME__H 10 | 11 | #include /* for size_t */ 12 | #include /* for struct tm */ 13 | 14 | size_t strftime_( 15 | char *s, 16 | size_t maxs, 17 | const char *f, 18 | const struct tm *t); 19 | 20 | #if defined(TZNAME_STD) && defined(TZNAME_DST) 21 | extern char *tzname_[2]; 22 | #endif 23 | 24 | #endif /* STRFTIME__H */ 25 | -------------------------------------------------------------------------------- /bindings/ruby/README: -------------------------------------------------------------------------------- 1 | # 2 | # ruby librrd bindings 3 | # author: Miles Egan 4 | # 5 | 6 | - Introduction 7 | 8 | This module provides ruby bindings for librrd, with functionality 9 | comparable to the native perl bindings. See test.rb for a script that 10 | exercises all ruby-librrd functionality. 11 | 12 | - Installation 13 | 14 | Installation is standard. Simply run: 15 | 16 | ruby extconf.rb 17 | make 18 | make install 19 | 20 | I hope this works for you. Please let me know if you have any 21 | problems or suggestions. Someday when I'm feeling less lazy I'll 22 | actually document this thing. Thanks to Tobi for rrdtool! 23 | -------------------------------------------------------------------------------- /bindings/perl-piped/rrdpl.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 5.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "rrd"=".\rrd.dsp" - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /src/rrd_version.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * RRDtool 1.4.3 Copyright by Tobi Oetiker, 1997-2010 3 | ***************************************************************************** 4 | * rrd_version Return 5 | ***************************************************************************** 6 | * Initial version by Burton Strauss, ntopSupport.com - 5/2005 7 | *****************************************************************************/ 8 | 9 | #include "rrd_tool.h" 10 | 11 | double rrd_version( 12 | void) 13 | { 14 | return NUMVERS; 15 | } 16 | 17 | char *rrd_strversion( 18 | void) 19 | { 20 | return PACKAGE_VERSION; 21 | } 22 | -------------------------------------------------------------------------------- /doc/rrdfirst.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | rrdfirst - Return the date of the first data sample in an RRA within an RRD 4 | 5 | =head1 SYNOPSIS 6 | 7 | B B I [I<--rraindex number>] 8 | 9 | =head1 DESCRIPTION 10 | 11 | The B function returns the UNIX timestamp of the first data 12 | sample entered into the specified RRA of the RRD file. 13 | 14 | =over 8 15 | 16 | =item I 17 | 18 | The name of the B that contains the data. 19 | 20 | =item I<--rraindex number> 21 | 22 | The index number of the B that is to be examined. If not specified, the 23 | index defaults to zero. B index numbers can be determined through 24 | B. 25 | 26 | =back 27 | 28 | =head1 AUTHOR 29 | 30 | Burton Strauss 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/rrd_i18n.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * RRDtool 1.4.3 Copyright by Takao Fujiwara, 2008 3 | ***************************************************************************** 4 | * rrd_i18n.h Common Header File 5 | *****************************************************************************/ 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | 11 | #ifndef _RRD_I18N_H 12 | #define _RRD_I18N_H 13 | 14 | #ifdef ENABLE_NLS 15 | # ifdef _LIBC 16 | # include 17 | # else 18 | # include "gettext.h" 19 | # define _(String) gettext (String) 20 | # endif 21 | #else 22 | # define _(String) (String) 23 | #endif 24 | 25 | #define N_(String) String 26 | 27 | #endif 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /src/rrd_nan_inf.c: -------------------------------------------------------------------------------- 1 | int done_nan = 0; 2 | int done_inf = 0; 3 | 4 | double dnan; 5 | double dinf; 6 | 7 | #if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) 8 | #include 9 | #include "rrd.h" 10 | 11 | #define NAN_FUNC (double)fmod(0.0,0.0) 12 | #define INF_FUNC (double)fabs((double)log(0.0)) 13 | 14 | #else 15 | #include "rrd.h" 16 | 17 | #define NAN_FUNC (double)(0.0/0.0) 18 | #define INF_FUNC (double)(1.0/0.0) 19 | 20 | #endif 21 | 22 | double rrd_set_to_DNAN( 23 | void) 24 | { 25 | if (!done_nan) { 26 | dnan = NAN_FUNC; 27 | done_nan = 1; 28 | } 29 | return dnan; 30 | } 31 | 32 | double rrd_set_to_DINF( 33 | void) 34 | { 35 | if (!done_inf) { 36 | dinf = INF_FUNC; 37 | done_inf = 1; 38 | } 39 | return dinf; 40 | } 41 | -------------------------------------------------------------------------------- /bindings/python/README: -------------------------------------------------------------------------------- 1 | Based on Python-RRDtool 0.2.1 2 | ----------------------------- 3 | 4 | The python-rrdtool provides a interface to rrdtool, the wonderful 5 | graphing and logging utility. This wrapper implementation has 6 | worked from the scratch (without SWIG), and it's under LGPL. 7 | 8 | This module have not documented yet. Please refer pydoc. 9 | 10 | 11 | Project 12 | ------- 13 | 14 | Homepage: http://www.nongnu.org/py-rrdtool/ 15 | 16 | Mailing Lists: 17 | 18 | CVS Checkins py-rrdtool-cvs@nongnu.org 19 | Users & Hackers py-rrdtool-users@nongnu.org 20 | 21 | 22 | Original Author 23 | --------------- 24 | 25 | Hye-Shik Chang 26 | 27 | Any comments, suggestions, and/or patches are very welcome. 28 | Thank you for using py-rrdtool! 29 | 30 | 31 | CHANGES 32 | ------- 33 | 2008-05-19 - tobi 34 | * rewrote the info method to conform to rrdtool info standard 35 | -------------------------------------------------------------------------------- /doc/rrdrestore.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | rrdrestore - Restore the contents of an RRD from its XML dump format 4 | 5 | =head1 SYNOPSIS 6 | 7 | B B I I 8 | S<[B<--range-check>|B<-r>]> 9 | 10 | =head1 DESCRIPTION 11 | 12 | The B function reads the XML representation of an RRD and converts 13 | it to the native B format. 14 | 15 | =over 8 16 | 17 | =item I 18 | 19 | The name of the B file you want to restore. 20 | 21 | =item I 22 | 23 | The name of the B to restore. 24 | 25 | =item B<--range-check>|B<-r> 26 | 27 | Make sure the values in the RRAs do not exceed the limits defined for 28 | the various data sources. 29 | 30 | =item B<--force-overwrite>|B<-f> 31 | 32 | Allows B to overwrite the destination B. 33 | 34 | =back 35 | 36 | =head1 AUTHOR 37 | 38 | Tobias Oetiker 39 | -------------------------------------------------------------------------------- /bindings/perl-piped/t/base.t: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl 2 | 3 | # this exercises just the perl module .. not RRDtool as such ... 4 | 5 | BEGIN { $| = 1; print "1..5\n"; } 6 | END { 7 | print "not ok 1\n" unless $loaded; 8 | unlink "demo.rrd"; 9 | } 10 | 11 | sub ok 12 | { 13 | $ok_count++; 14 | my($what, $result) = @_ ; 15 | print "not " unless $result; 16 | print "ok $ok_count $what\n"; 17 | } 18 | 19 | use RRDp; 20 | 21 | $loaded = 1; 22 | $ok_count = 1; 23 | 24 | print "ok 1 module load\n"; 25 | 26 | ok("RRDp::start", RRDp::start "../../src/rrdtool" > 0); 27 | 28 | $now=time(); 29 | RRDp::cmd qw(create demo.rrd --start ), $now, qw(--step 100 ), 30 | qw( DS:in:GAUGE:100:U:U RRA:AVERAGE:0.5:1:10 ); 31 | 32 | $answer = RRDp::read; 33 | ok("RRDp::cmd", -s "demo.rrd" ); 34 | 35 | RRDp::cmd qw(last demo.rrd); 36 | $answer = RRDp::read; 37 | 38 | ok("RRDp::read", $$answer =~ /$now/); 39 | 40 | $status = RRDp::end; 41 | 42 | ok("RRDp::end", $status == 0); 43 | -------------------------------------------------------------------------------- /win32/rrdtool.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "rrd"=".\rrd.dsp" - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Project: "rrdtool"=".\rrdtool.dsp" - Package Owner=<4> 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<4> 25 | {{{ 26 | Begin Project Dependency 27 | Project_Dep_Name rrd 28 | End Project Dependency 29 | }}} 30 | 31 | ############################################################################### 32 | 33 | Global: 34 | 35 | Package=<5> 36 | {{{ 37 | }}} 38 | 39 | Package=<3> 40 | {{{ 41 | }}} 42 | 43 | ############################################################################### 44 | 45 | -------------------------------------------------------------------------------- /src/rrd_is_thread_safe.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * RRDtool 1.4.3 Copyright by Tobi Oetiker, 1997-2010 3 | * This file: Copyright 2003 Peter Stamfest 4 | * & Tobias Oetiker 5 | * Distributed under the GPL 6 | ***************************************************************************** 7 | * rrd_is_thread_safe.c Poisons some nasty function calls using GNU cpp 8 | ***************************************************************************** 9 | * $Id$ 10 | *************************************************************************** */ 11 | 12 | #ifndef _RRD_IS_THREAD_SAFE_H 13 | #define _RRD_IS_THREAD_SAFE_H 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | #undef strerror 20 | 21 | #if( 2 < __GNUC__ ) 22 | #pragma GCC poison strtok asctime ctime gmtime localtime tmpnam strerror 23 | #endif 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | #endif /*_RRD_IS_THREAD_SAFE_H */ 29 | -------------------------------------------------------------------------------- /doc/rrdtool-xport.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /examples/cgi-demo.cgi.in: -------------------------------------------------------------------------------- 1 | #! @exec_prefix@/bin/rrdcgi 2 | 3 | 4 | 5 | RRDCGI Demo 6 | 7 | 8 | Note: This Demo will only work if have previously run 9 | the shared-demo.pl. 10 | 11 |

This is NOT traffic

12 | 13 | 14 |

" 18 | DEF:alpha=shared-demo.rrd:a:AVERAGE 19 | DEF:beta=shared-demo.rrd:b:AVERAGE 20 | AREA:alpha#0022e9:"Trees on Mars" 21 | STACK:beta#00b871:"Elchs in Norway"> 22 |

23 | 24 |

25 | 33 |

34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/rrd_xport.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * RRDtool 1.4.3 Copyright by Tobi Oetiker, 1997-2010 3 | **************************************************************************** 4 | * rrd_xport.h contains XML related constants 5 | ****************************************************************************/ 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #ifndef _RRD_XPORT_H 11 | #define _RRD_XPORT_H 12 | 13 | #define XML_ENCODING "ISO-8859-1" 14 | #define ROOT_TAG "xport" 15 | #define META_TAG "meta" 16 | #define META_START_TAG "start" 17 | #define META_STEP_TAG "step" 18 | #define META_END_TAG "end" 19 | #define META_ROWS_TAG "rows" 20 | #define META_COLS_TAG "columns" 21 | #define LEGEND_TAG "legend" 22 | #define LEGEND_ENTRY_TAG "entry" 23 | #define DATA_TAG "data" 24 | #define DATA_ROW_TAG "row" 25 | #define COL_TIME_TAG "t" 26 | #define COL_DATA_TAG "v" 27 | 28 | 29 | #endif 30 | 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | -------------------------------------------------------------------------------- /src/librrd.sym.in.in: -------------------------------------------------------------------------------- 1 | rrd_add_ptr 2 | rrd_add_strdup 3 | rrd_add_ptr_chunk 4 | rrd_add_strdup_chunk 5 | rrd_clear_error 6 | rrd_close 7 | rrd_create 8 | rrd_create_r 9 | rrd_dontneed 10 | rrd_dump 11 | rrd_dump_r 12 | rrd_dump_cb_r 13 | rrd_fetch 14 | rrd_fetch_r 15 | rrd_flushcached 16 | rrd_first 17 | rrd_first_r 18 | rrd_flush 19 | rrd_free 20 | rrd_free_context 21 | rrd_free_ptrs 22 | rrd_freemem 23 | rrd_get_context 24 | rrd_get_error 25 | rrd_graph 26 | rrd_graph_v 27 | rrd_info 28 | rrd_info_free 29 | rrd_info_print 30 | rrd_info_push 31 | rrd_info_r 32 | rrd_init 33 | rrd_last 34 | rrd_last_r 35 | rrd_lastupdate 36 | rrd_lastupdate_r 37 | rrd_lock 38 | rrd_mkdir_p 39 | rrd_new_context 40 | rrd_open 41 | rrd_parsetime 42 | rrd_proc_start_end 43 | rrd_random 44 | rrd_read 45 | rrd_resize 46 | rrd_restore 47 | rrd_seek 48 | rrd_set_error 49 | rrd_set_to_DINF 50 | rrd_set_to_DNAN 51 | rrd_strerror 52 | rrd_strversion 53 | rrd_tell 54 | rrd_test_error 55 | rrd_tune 56 | rrd_update 57 | rrd_update_r 58 | rrd_update_v 59 | rrd_update_v_r 60 | rrd_version 61 | rrd_write 62 | rrd_xport 63 | rrdc_connect 64 | rrdc_is_connected 65 | rrdc_disconnect 66 | rrdc_flush 67 | rrdc_stats_free 68 | rrdc_stats_get 69 | rrdc_update 70 | @RRD_GETOPT_LONG@ 71 | -------------------------------------------------------------------------------- /etc/rrdcached-init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # chkconfig: 2345 19 81 4 | # description: rrdcached startup script 5 | # 6 | 7 | RRDCACHED=/usr/bin/rrdcached 8 | 9 | . /etc/rc.d/init.d/functions 10 | 11 | . /etc/default/rrdcached 12 | 13 | RETVAL=0 14 | 15 | case "$1" in 16 | start) 17 | if [ ${RUN_RRDCACHED} -eq 0 ]; 18 | then 19 | echo "Please enable rrdcached in /etc/default/rrdcached" 20 | exit 0 21 | fi 22 | 23 | echo -n "Starting rrdcached: " 24 | [ -f $RRDCACHED ] || exit 1 25 | 26 | daemon --user=$RRDCACHED_USER \ 27 | $RRDCACHED $OPTS -p $PIDFILE -l $SOCKFILE 28 | RETVAL=$? 29 | echo 30 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/rrdcached 31 | [ $RETVAL -eq 0 ] && chmod $SOCKPERMS "${SOCKFILE}" 32 | ;; 33 | 34 | stop) 35 | echo -n "Shutting down rrdcached: " 36 | killproc rrdcached 37 | RETVAL=$? 38 | echo 39 | [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/rrdcached && rm -rf $PIDFILE 40 | ;; 41 | 42 | restart|reload) 43 | $0 stop 44 | $0 start 45 | RETVAL=$? 46 | ;; 47 | status) 48 | status rrdcached 49 | RETVAL=$? 50 | ;; 51 | *) 52 | echo "Usage: $0 {start|stop|restart|status}" 53 | exit 1 54 | esac 55 | 56 | exit $RETVAL 57 | 58 | -------------------------------------------------------------------------------- /bindings/perl-shared/ntmake-build: -------------------------------------------------------------------------------- 1 | use ExtUtils::MakeMaker; 2 | use Config; 3 | # See lib/ExtUtils/MakeMaker.pm for details of how to influence 4 | # the contents of the Makefile that is written. 5 | # Run VCVARS32.BAT before generating makefile/compiling. 6 | WriteMakefile( 7 | 'NAME' => 'RRDs', 8 | 'VERSION_FROM' => 'RRDs.pm', 9 | # 'DEFINE' => "-DPERLPATCHLEVEL=$Config{PATCHLEVEL}", 10 | # keep compatible w/ ActiveState 5xx builds 11 | 'DEFINE' => "-DPERLPATCHLEVEL=5", 12 | 13 | 'INC' => '-I../../src/ "-I/Program Files/GnuWin32/include"', 14 | # Since we are now using GnuWin32 libraries dynamically (instead of static 15 | # complile with code redistributed with rrdtool), use /MD instead of /MT. 16 | # Yes, this means we need msvcrt.dll but GnuWin32 dlls already require it 17 | # and it is available on most versions of Windows. 18 | 'OPTIMIZE' => '-O2 -MD', 19 | 'LIBS' => '../../src/release/rrd.lib "/Program Files/GnuWin32/lib/libart_lgpl.lib" "/Program Files/GnuWin32/lib/libz.lib" "/Program Files/GnuWin32/lib/libpng.lib" "/Program Files/GnuWin32/lib/libfreetype.lib"', 20 | 'realclean' => {FILES => 't/demo?.rrd t/demo?.png' }, 21 | ($] ge '5.005') ? ( 22 | 'AUTHOR' => 'Tobias Oetiker (tobi@oetiker.ch)', 23 | 'ABSTRACT' => 'Round Robin Database Tool', 24 | ) : () 25 | 26 | 27 | ); 28 | -------------------------------------------------------------------------------- /src/plbasename.h: -------------------------------------------------------------------------------- 1 | #ifdef WIN32 2 | /* 3 | * 4 | * Cross-platform basename/dirname 5 | * 6 | * Copyright 2005 Syd Logan, All Rights Reserved 7 | * 8 | * This code is distributed without warranty. You are free to use this 9 | * code for any purpose, however, if this code is republished or 10 | * redistributed in its original form, as hardcopy or electronically, 11 | * then you must include this copyright notice along with the code. 12 | * 13 | */ 14 | 15 | // minor changes 2008 by Stefan Ludewig stefan.ludewig@exitgames.com for WIN32 version RRDtool 16 | 17 | #if !defined(__PL_BASENAME_H__) 18 | #define __PL_BASENAME_H__ 19 | 20 | /* 21 | path dirname basename 22 | "/usr/lib" "/usr" "lib" 23 | "/usr/" "/" "usr" 24 | "usr" "." "usr" 25 | "/" "/" "/" 26 | "." "." "." 27 | ".." "." ".." 28 | */ 29 | 30 | #if defined(__cplusplus) 31 | extern "C" { 32 | #endif 33 | 34 | const char *PL_basename(const char *name); 35 | const char *PL_dirname(const char *name); 36 | 37 | #define basename(name) ((char*)PL_basename(name)) 38 | #define dirname(name) ((char*)PL_dirname(name)) 39 | 40 | #if defined(__cplusplus) 41 | } 42 | #endif 43 | 44 | #endif 45 | #endif // WIN32 46 | -------------------------------------------------------------------------------- /examples/minmax.pl.in: -------------------------------------------------------------------------------- 1 | #! @PERL@ 2 | 3 | use lib qw( @prefix@/lib/perl ); 4 | 5 | use RRDs; 6 | my $start=time; 7 | my $rrd="randome.rrd"; 8 | my $name = $0; 9 | $name =~ s/.*\///g; 10 | $name =~ s/\.pl.*//g; 11 | 12 | RRDs::create ($rrd, "--start",$start-1, "--step",300, 13 | "DS:a:GAUGE:600:U:U", 14 | "RRA:AVERAGE:0.5:1:300", 15 | "RRA:MIN:0.5:12:300", 16 | "RRA:MAX:0.5:12:300", 17 | ); 18 | my $ERROR = RRDs::error; 19 | die "$0: unable to create `$rrd': $ERROR\n" if $ERROR; 20 | 21 | # dropt some data into the rrd 22 | my $t; 23 | for ($t=$start; $t<$start+300*300; $t+=300){ 24 | RRDs::update $rrd, "$t:".(sin($t/3000)*50+50); 25 | if ($ERROR = RRDs::error) { 26 | die "$0: unable to update `$rrd': $ERROR\n"; 27 | } 28 | } 29 | 30 | RRDs::graph "$name.png", 31 | "--title", uc($name)." Demo", 32 | "--start", "now", 33 | "--end", "start+1d", 34 | "--lower-limit=0", 35 | "--interlace", 36 | "--imgformat","PNG", 37 | "--width=450", 38 | "DEF:a=$rrd:a:AVERAGE", 39 | "DEF:b=$rrd:a:MIN", 40 | "DEF:c=$rrd:a:MAX", 41 | "AREA:a#00b6e4:real", 42 | "LINE1:b#0022e9:min", 43 | "LINE1:c#00ee22:max", 44 | ; 45 | 46 | if ($ERROR = RRDs::error) { 47 | die "ERROR: $ERROR\n"; 48 | }; 49 | 50 | 51 | print "This script has created $name.png in the current directory\n"; 52 | print "This demonstrates the use of MIN and MAX archives\n"; 53 | -------------------------------------------------------------------------------- /doc/rrdtool-dump.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /doc/rrdlast.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | rrdlast - Return the date of the last data sample in an RRD 4 | 5 | =head1 SYNOPSIS 6 | 7 | B B I 8 | S<[B<--daemon> I
]> 9 | 10 | =head1 DESCRIPTION 11 | 12 | The B function returns the UNIX timestamp of the most recent 13 | update of the RRD. 14 | 15 | =over 8 16 | 17 | =item I 18 | 19 | The name of the B that contains the data. 20 | 21 | =item B<--daemon> I
22 | 23 | Address of the L daemon. If specified, a C command is sent 24 | to the server before reading the RRD files. This allows B to return 25 | fresh data even if the daemon is configured to cache values for a long time. 26 | For a list of accepted formats, see the B<-l> option in the L manual. 27 | 28 | rrdtool last --daemon unix:/var/run/rrdcached.sock /var/lib/rrd/foo.rrd 29 | 30 | =back 31 | 32 | =head1 ENVIRONMENT VARIABLES 33 | 34 | The following environment variables may be used to change the behavior of 35 | Clast>: 36 | 37 | =over 4 38 | 39 | =item B 40 | 41 | If this environment variable is set it will have the same effect as specifying 42 | the C<--daemon> option on the command line. If both are present, the command 43 | line argument takes precedence. 44 | 45 | =back 46 | 47 | =head1 AUTHOR 48 | 49 | Russ Wright 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/rrdupdate.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * RRDtool 1.4.3 Copyright by Tobi Oetiker, 1997-2010 3 | ***************************************************************************** 4 | * rrdupdate.c Main program for the (standalone) rrdupdate utility 5 | ***************************************************************************** 6 | * $Id$ 7 | *****************************************************************************/ 8 | 9 | #if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) && !defined(HAVE_CONFIG_H) 10 | #include "../win32/config.h" 11 | #else 12 | #ifdef HAVE_CONFIG_H 13 | #include "../rrd_config.h" 14 | #endif 15 | #endif 16 | 17 | #include "rrd.h" 18 | 19 | int main( 20 | int argc, 21 | char **argv) 22 | { 23 | rrd_update(argc, argv); 24 | if (rrd_test_error()) { 25 | printf("RRDtool " PACKAGE_VERSION 26 | " Copyright by Tobi Oetiker, 1997-2008\n\n" 27 | "Usage: rrdupdate filename\n" 28 | "\t\t\t[--template|-t ds-name:ds-name:...]\n" 29 | "\t\t\ttime|N:value[:value...]\n\n" 30 | "\t\t\tat-time@value[:value...]\n\n" 31 | "\t\t\t[ time:value[:value...] ..]\n\n"); 32 | 33 | printf("ERROR: %s\n", rrd_get_error()); 34 | rrd_clear_error(); 35 | return 1; 36 | } 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /examples/bigtops.pl.in: -------------------------------------------------------------------------------- 1 | #! @PERL@ 2 | # this is for after install 3 | use lib qw( @prefix@/lib/perl ); 4 | 5 | use RRDs; 6 | my $start=time; 7 | my $rrd="randome.rrd"; 8 | my $name = $0; 9 | $name =~ s/.*\///g; 10 | $name =~ s/\.pl.*//g; 11 | 12 | RRDs::create ($rrd, "--start",$start-1, "--step",300, 13 | "DS:a:GAUGE:600:U:U", 14 | "DS:b:GAUGE:600:U:U", 15 | "RRA:AVERAGE:0.5:1:300"); 16 | my $ERROR = RRDs::error; 17 | die "$0: unable to create `$rrd': $ERROR\n" if $ERROR; 18 | 19 | # dropt some data into the rrd 20 | my $t; 21 | for ($t=$start; $t<$start+300*300; $t+=300){ 22 | RRDs::update $rrd, "$t:".rand(100).":".(sin($t/800)*50+50); 23 | if ($ERROR = RRDs::error) { 24 | die "$0: unable to update `$rrd': $ERROR\n"; 25 | } 26 | } 27 | 28 | RRDs::graph "$name.png", 29 | "--title", uc($name)." Demo", 30 | "--start", "$start + 1 h", 31 | "--end", "start + 1000 min", 32 | "--interlace", 33 | "--imgformat","PNG", 34 | "--width=450", 35 | "DEF:a=$rrd:a:AVERAGE", 36 | "DEF:b=$rrd:b:AVERAGE", 37 | "CDEF:line=TIME,2400,%,300,LT,a,UNKN,IF", 38 | "AREA:b#00b6e4:beta", 39 | "AREA:line#0022e9:alpha", 40 | "LINE3:line#ff0000", 41 | 42 | ; 43 | 44 | if ($ERROR = RRDs::error) { 45 | die "ERROR: $ERROR\n"; 46 | }; 47 | 48 | 49 | print "This script has created $name.png in the current directory\n"; 50 | print "This demonstrates the use of the TIME and % RPN operators\n"; 51 | -------------------------------------------------------------------------------- /src/rrd_hw_update.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * rrd_hw_update.h Functions for updating a Holt-Winters RRA 3 | ****************************************************************************/ 4 | 5 | int update_hwpredict( 6 | rrd_t *rrd, 7 | unsigned long cdp_idx, 8 | unsigned long rra_idx, 9 | unsigned long ds_idx, 10 | unsigned short CDP_scratch_idx, 11 | hw_functions_t * functions); 12 | 13 | int update_seasonal( 14 | rrd_t *rrd, 15 | unsigned long cdp_idx, 16 | unsigned long rra_idx, 17 | unsigned long ds_idx, 18 | unsigned short CDP_scratch_idx, 19 | rrd_value_t *seasonal_coef, 20 | hw_functions_t * functions); 21 | 22 | int update_devpredict( 23 | rrd_t *rrd, 24 | unsigned long cdp_idx, 25 | unsigned long rra_idx, 26 | unsigned long ds_idx, 27 | unsigned short CDP_scratch_idx); 28 | 29 | int update_devseasonal( 30 | rrd_t *rrd, 31 | unsigned long cdp_idx, 32 | unsigned long rra_idx, 33 | unsigned long ds_idx, 34 | unsigned short CDP_scratch_idx, 35 | rrd_value_t *seasonal_dev, 36 | hw_functions_t * functions); 37 | 38 | int update_failures( 39 | rrd_t *rrd, 40 | unsigned long cdp_idx, 41 | unsigned long rra_idx, 42 | unsigned long ds_idx, 43 | unsigned short CDP_scratch_idx, 44 | hw_functions_t * functions); 45 | -------------------------------------------------------------------------------- /doc/rrdlastupdate.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | rrdlastupdate - Return the most recent update to an RRD 4 | 5 | =head1 SYNOPSIS 6 | 7 | B B I 8 | S<[B<--daemon> I
]> 9 | 10 | =head1 DESCRIPTION 11 | 12 | The B function returns the UNIX timestamp and the 13 | value stored for each datum in the most recent update of an RRD. 14 | 15 | =over 8 16 | 17 | =item I 18 | 19 | The name of the B that contains the data. 20 | 21 | =item B<--daemon> I
22 | 23 | Address of the L daemon. If specified, a C command is sent 24 | to the server before reading the RRD files. This allows B to return 25 | fresh data even if the daemon is configured to cache values for a long time. 26 | For a list of accepted formats, see the B<-l> option in the L manual. 27 | 28 | rrdtool lastupdate --daemon unix:/var/run/rrdcached.sock /var/lib/rrd/foo.rrd 29 | 30 | =back 31 | 32 | =head1 ENVIRONMENT VARIABLES 33 | 34 | The following environment variables may be used to change the behavior of 35 | Clastupdate>: 36 | 37 | =over 4 38 | 39 | =item B 40 | 41 | If this environment variable is set it will have the same effect as specifying 42 | the C<--daemon> option on the command line. If both are present, the command 43 | line argument takes precedence. 44 | 45 | =back 46 | 47 | =head1 AUTHOR 48 | 49 | Andy Riebs Eandy.riebs@hp.comE 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /bindings/dotnet/rrdlib.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual Studio 2008 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dnrrdlib", "dnrrdlib.csproj", "{0688ED86-0E5F-4469-A7DB-D51024DE99E9}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dnrrd_binding_test", "dnrrd_binding_test.csproj", "{2BB82CAE-A379-46D9-B2B5-13DC4DB3209C}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {0688ED86-0E5F-4469-A7DB-D51024DE99E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {0688ED86-0E5F-4469-A7DB-D51024DE99E9}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {0688ED86-0E5F-4469-A7DB-D51024DE99E9}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {0688ED86-0E5F-4469-A7DB-D51024DE99E9}.Release|Any CPU.Build.0 = Release|Any CPU 18 | {2BB82CAE-A379-46D9-B2B5-13DC4DB3209C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {2BB82CAE-A379-46D9-B2B5-13DC4DB3209C}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {2BB82CAE-A379-46D9-B2B5-13DC4DB3209C}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {2BB82CAE-A379-46D9-B2B5-13DC4DB3209C}.Release|Any CPU.Build.0 = Release|Any CPU 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /examples/stripes.pl.in: -------------------------------------------------------------------------------- 1 | #! @PERL@ 2 | use lib qw( @prefix@/lib/perl ); 3 | 4 | use strict; 5 | use vars qw(@ISA $loaded); 6 | 7 | use RRDs; 8 | my $start=time; 9 | my $rrd="random.rrd"; 10 | RRDs::create ($rrd, "--start",$start-1, "--step",300, 11 | "DS:a:GAUGE:600:U:U", 12 | "DS:b:GAUGE:600:U:U", 13 | "RRA:AVERAGE:0.5:1:200"); 14 | my $ERROR = RRDs::error; 15 | die "$0: unable to create `$rrd': $ERROR\n" if $ERROR; 16 | my $t; 17 | for ($t=$start; $t<$start+200*300; $t+=300){ 18 | RRDs::update $rrd, "$t:".rand(100).":".(sin($t/800)*50+50); 19 | if ($ERROR = RRDs::error) { 20 | die "$0: unable to update `$rrd': $ERROR\n"; 21 | } 22 | } 23 | RRDs::graph "stripes.png", 24 | "--title", "Stripes Demo", 25 | "--start", $start, 26 | "--end", "start + 400 min", 27 | "--interlace", 28 | "--imgformat","PNG", 29 | "--width=450", 30 | "DEF:a=$rrd:a:AVERAGE", 31 | "DEF:b=$rrd:b:AVERAGE", 32 | "CDEF:alpha=TIME,1200,%,600,LT,a,UNKN,IF", 33 | "CDEF:beta=TIME,1200,%,600,GE,b,UNKN,IF", 34 | "AREA:alpha#0022e9:alpha", 35 | "AREA:beta#00b674:beta", 36 | "LINE1:b#ff4400:beta envelope\\c", 37 | "COMMENT:\\s", 38 | "COMMENT:alpha=TIME,1200,%,600,LT,a,UNKN,IF", 39 | "COMMENT:beta=TIME,1200,%,600,GE,b,UNKN,IF\\j"; 40 | if ($ERROR = RRDs::error) { 41 | die "ERROR: $ERROR\n"; 42 | }; 43 | 44 | 45 | print "This script has created stripes.png in the current directory\n"; 46 | print "This demonstrates the use of the TIME and % RPN operators\n"; 47 | -------------------------------------------------------------------------------- /doc/rrdresize.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | rrdresize - alters the size of an RRA and creates a new .rrd file 4 | 5 | =head1 SYNOPSIS 6 | 7 | B B I I BI<|>B I 8 | 9 | =head1 DESCRIPTION 10 | 11 | The B function is used to modify the number of rows in 12 | an B. 13 | 14 | =over 8 15 | 16 | =item I 17 | 18 | the name of the B you want to alter. 19 | 20 | =item I 21 | 22 | the B you want to alter. You can find the number using B. 23 | 24 | =item B 25 | 26 | used if you want to add extra rows to an RRA. The extra rows will be inserted 27 | as the rows that are oldest. 28 | 29 | =item B 30 | 31 | used if you want to remove rows from an RRA. The rows that will be removed 32 | are the oldest rows. 33 | 34 | =item I 35 | 36 | the number of rows you want to add or remove. 37 | 38 | =back 39 | 40 | =head1 NOTES 41 | 42 | The new .rrd file, with the modified RRAs, is written to the file 43 | B in the current directory. B. 45 | 46 | It is possible to abuse this tool and get strange results 47 | by first removing some rows and then reinserting the same amount (effectively 48 | clearing them to be Unknown). You may thus end up with unknown data in one 49 | RRA while at the same timestamp this data is available in another RRA. 50 | 51 | =head1 AUTHOR 52 | 53 | Alex van den Bogaerdt 54 | 55 | -------------------------------------------------------------------------------- /bindings/tcl/ifOctets.tcl.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # the next line restarts using tclsh -*- tcl -*- \ 3 | exec tclsh@TCL_VERSION@ "$0" "$@" 4 | 5 | #package require Tnm 3.0 6 | package require Rrd @VERSION@ 7 | 8 | set rrdfile "[lindex $argv 0]-[lindex $argv 1].rrd" 9 | 10 | # create rrdfile if not yet existent 11 | if {[file exists $rrdfile] == 0} { 12 | Rrd::create $rrdfile --step 5 \ 13 | DS:inOctets:COUNTER:10:U:U DS:outOctets:COUNTER:10:U:U \ 14 | RRA:AVERAGE:0.5:1:12 15 | } 16 | 17 | # get an snmp session context 18 | set session [Tnm::snmp generator -address [lindex $argv 0]] 19 | 20 | # walk through the ifDescr column to find the right interface 21 | $session walk descr IF-MIB!ifDescr { 22 | 23 | # is this the right interface? 24 | if {"[Tnm::snmp value $descr 0]" == "[lindex $argv 1]"} { 25 | 26 | # get the instance part of this table row 27 | set inst [lindex [Tnm::mib split [Tnm::snmp oid $descr 0]] 1] 28 | 29 | # get the two interface's octet counter values 30 | set in [lindex [lindex [$session get IF-MIB!ifInOctets.$inst] 0] 2] 31 | set out [lindex [lindex [$session get IF-MIB!ifOutOctets.$inst] 0] 2] 32 | 33 | # write the values to the rrd 34 | puts "$in $out" 35 | Rrd::update $rrdfile --template inOctets:outOctets N:$in:$out 36 | 37 | Rrd::graph gaga.png --title "gaga" \ 38 | DEF:in=$rrdfile:inOctets:AVERAGE \ 39 | DEF:out=$rrdfile:outOctets:AVERAGE \ 40 | AREA:in#0000FF:inOctets \ 41 | LINE2:out#00C000:outOctets 42 | 43 | #puts [Rrd::fetch $rrdfile AVERAGE] 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/rrd_not_thread_safe.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * RRDtool 1.4.3 Copyright by Tobi Oetiker, 1997-2010 3 | * This file: Copyright 2003 Peter Stamfest 4 | * & Tobias Oetiker 5 | * Distributed under the GPL 6 | ***************************************************************************** 7 | * rrd_not_thread_safe.c Contains routines used when thread safety is not 8 | * an issue 9 | ***************************************************************************** 10 | * $Id$ 11 | *************************************************************************** */ 12 | #include "rrd.h" 13 | #include "rrd_tool.h" 14 | #define MAXLEN 4096 15 | #define ERRBUFLEN 256 16 | 17 | /* The global context is very useful in the transition period to even 18 | more thread-safe stuff, it can be used whereever we need a context 19 | and do not need to worry about concurrency. */ 20 | static rrd_context_t global_ctx = { 21 | "", 22 | "" 23 | }; 24 | 25 | /* #include */ 26 | 27 | rrd_context_t *rrd_get_context( 28 | void) 29 | { 30 | return &global_ctx; 31 | } 32 | 33 | /* how ugly that is!!! - make sure strerror is what it should be. It 34 | might be redefined to help in keeping other modules thread safe by 35 | silently turning misplaced strerror into rrd_strerror, but here 36 | this turns recursive! */ 37 | #undef strerror 38 | const char *rrd_strerror( 39 | int err) 40 | { 41 | return strerror(err); 42 | } 43 | -------------------------------------------------------------------------------- /src/get_ver.awk: -------------------------------------------------------------------------------- 1 | # **************************************************************************** 2 | # RRDtool 1.2.19 Copyright by Tobi Oetiker, 1997-2007 3 | # **************************************************************************** 4 | # get_ver.awk AWK Script for non-configure builds 5 | # **************************************************************************** 6 | # $Id: get_ver.awk 1000 2007-14-02 05:51:34Z oetiker $ 7 | # **************************************************************************** 8 | BEGIN { 9 | # fetch rrdtool version number from input file and write them to STDOUT 10 | while ((getline < ARGV[1]) > 0) { 11 | if (match ($0, /^AC_INIT/)) { 12 | split($1, t, ","); 13 | my_ver_str = substr(t[2],2,length(t[2])-3); 14 | split(my_ver_str, v, "."); 15 | gsub("[^0-9].*$", "", v[3]); 16 | my_ver = v[1] "," v[2] "," v[3]; 17 | } 18 | if (match ($0, /^NUMVERS=/)) { 19 | split($1, t, "="); 20 | my_ver_num = t[2]; 21 | } 22 | } 23 | # read from from input file, replace placeholders, and write to STDOUT 24 | if (ARGV[2]) { 25 | while ((getline < ARGV[2]) > 0) { 26 | if (match ($0, /@@NUMVERS@@/)) { 27 | gsub("@@NUMVERS@@", my_ver_num, $0); 28 | } 29 | if (match ($0, /@@PACKAGE_VERSION@@/)) { 30 | gsub("@@PACKAGE_VERSION@@", "" my_ver_str "", $0); 31 | } 32 | print; 33 | } 34 | } else { 35 | print "RRD_VERSION = " my_ver ""; 36 | print "RRD_VERSION_STR = " my_ver_str ""; 37 | print "RRD_NUMVERS = " my_ver_num ""; 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /doc/rrdflushcached.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | rrdflushcached - Flush the values for a spcific RRD file from memory. 4 | 5 | =head1 SYNOPSIS 6 | 7 | B B 8 | S<[B<--daemon> I
]> 9 | I [I ...] 10 | 11 | =head1 DESCRIPTION 12 | 13 | The B function connects to L, the RRD caching daemon, 14 | and issues a "flush" command for the given files. The daemon will put the 15 | files to the head of the update queue so they are written "soon". The 16 | status will be returned only after the files' pending updates have been 17 | written to disk. 18 | 19 | =over 8 20 | 21 | =item I 22 | 23 | The name(s) of the B file(s) that are to be written to disk. 24 | 25 | =item B<--daemon> I
26 | 27 | Address of the L daemon. If not specified, the 28 | RRDCACHED_ADDRESS environment variable must be set (see below). For a 29 | list of accepted formats, see the B<-l> option in the L 30 | manual. 31 | 32 | rrdtool flush --daemon unix:/var/run/rrdcached.sock /var/lib/rrd/foo.rrd 33 | 34 | =back 35 | 36 | =head1 ENVIRONMENT VARIABLES 37 | 38 | The following environment variables may be used to change the behavior of 39 | Cflushcached>: 40 | 41 | =over 4 42 | 43 | =item B 44 | 45 | If this environment variable is set it will have the same effect as specifying 46 | the C<--daemon> option on the command line. If both are present, the command 47 | line argument takes precedence. 48 | 49 | =back 50 | 51 | =head1 AUTHOR 52 | 53 | Florian Forster EoctoEatEverplant.orgE 54 | -------------------------------------------------------------------------------- /bindings/tcl/README: -------------------------------------------------------------------------------- 1 | TCLRRD -- A TCL interpreter extension to access the RRD library, 2 | contributed to Tobias Oetiker's RRD tools. 3 | 4 | Copyright (c) 1999,2000 Frank Strauss, Technical University of Braunschweig. 5 | 6 | See the file "COPYING" for information on usage and redistribution 7 | of this file, and for a DISCLAIMER OF ALL WARRANTIES. 8 | 9 | TCLRRD adds a dynamically loadable package to the Tcl 8.x interpreter 10 | to access all RRD functions as of RRDtool 1.0.13. All command names 11 | and arguments are equal to those of RRDtool. They are assigned to the 12 | namespace `Rrd', e.g. `Rrd::create'. Return values are a bit 13 | different from plain RRDtool behavior to enable more native Tcl 14 | usage. Errors are mapped to the TCL_ERROR return code together with 15 | the RRD error strings. 16 | 17 | TCLRRD makes it easy to combine RRD use with advanced SNMP functionality 18 | of scotty (http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/). E.g., it's easy 19 | to use some scotty code to get the counters of some interfaces by their 20 | interface name and then use Rrd::update to store the values. Furthermore, 21 | data source types (see RRD::create documentation) and integer value ranges 22 | could be easily retrieved from MIB information. 23 | 24 | TCLRRD has been written on a Linux system for use with Tcl 8.x. It should 25 | work on many other platforms, although it has not been tested. There are 26 | no fool proof installation procedures. Take a look at Makefile.am and 27 | adapt it, if required. 28 | 29 | TCLRRD has been written for RRD 1.0.13. 30 | 31 | Frank Strauss , 09-Mar-2000 32 | -------------------------------------------------------------------------------- /MakeMakefile: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Run this script after the first cvs checkout to build 4 | # makefiles and friends 5 | 6 | PATH="/usr/pack/automake-1.11-to/amd64-linux-debian3.1/:/usr/pack/automake-1.11-to/amd64-linux-ubuntu8.04/bin:/usr/pack/gettext-0.18.1.1-to/amd64-linux-ubuntu8.04/bin:$PATH" 7 | export PATH 8 | 9 | vcheck (){ 10 | perl </dev/null` == 'Darwin' ] 27 | then 28 | LIBTOOL_BIN="glibtool" 29 | fi 30 | 31 | if vcheck $LIBTOOL_VER "$LIBTOOL_BIN --version" 32 | then 33 | echo "get a copy of GNU libtool >= $LIBTOOL_VER" 34 | ERROR=1 35 | fi 36 | 37 | if vcheck $AUTOMAKE_VER "automake --version" 38 | then 39 | if vcheck $AUTOMAKE_VER "automake-1.11 --version" 40 | then 41 | echo "get a copy of GNU automake >= $AUTOMAKE_VER" 42 | ERROR=1 43 | else 44 | AUTOMAKE="automake-1.11" 45 | ACLOCAL="aclocal-1.11" 46 | export AUTOMAKE ACLOCAL 47 | fi 48 | fi 49 | 50 | 51 | if vcheck $AUTOCONF_VER "autoconf --version" 52 | then 53 | echo "get a copy of GNU autoconf >= $autoconf_ver" 54 | ERROR=1 55 | fi 56 | 57 | if [ $ERROR -ne 0 ] 58 | then 59 | exit 1 60 | fi 61 | 62 | ./autogen.sh 63 | 64 | # vim: set syntax=sh : 65 | -------------------------------------------------------------------------------- /bindings/dotnet/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("rrdlib")] 9 | [assembly: AssemblyDescription(".NET bindings for rrdlib")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Euphoria Audio, LLC")] 12 | [assembly: AssemblyProduct("RRDLib Dot Net Binding")] 13 | [assembly: AssemblyCopyright("Copyright © Chris Larsen 2010")] 14 | [assembly: AssemblyTrademark("rrdlib by Tobias Oetiker")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("841fc684-688e-4f72-9e7e-1f367f53b227")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("0.9.1.5")] 36 | [assembly: AssemblyFileVersion("0.9.1.5")] 37 | -------------------------------------------------------------------------------- /rrdtool-1.2-release: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | VERSION=`perl -n -e 'm/\QAC_INIT([rrdtool],[\E(.+?)\Q])\E/ && print $1' configure.ac` 4 | PERLVERS=`perl -n -e 'm/NUMVERS=(\d+\.\d+)/ && print $1' configure.ac` 5 | set -x 6 | perl -i -p -e 's/^\$VERSION.+/\$VERSION='$PERLVERS';/' bindings/perl-*/*.pm 7 | perl -i -p -e 's/RRDtool 1\S+/RRDtool '$VERSION'/ && s/Copyright.+?Oetiker.+\d{4}/Copyright by Tobi Oetiker, 1997-2007/' src/*.h src/*.c 8 | perl -i -p -e 's/^Version:.+/Version: '$VERSION'/' rrdtool.spec 9 | perl -i -p -e 's/rrdtool-[\.\d]+\d(pre\d+)?(rc\d+)?/rrdtool-'$VERSION'/g' doc/rrdbuild.pod 10 | svn diff 11 | echo "Tagging and releasing rrdtool $VERSION ($PERLVERS). Press any Key to continue." 12 | read somekey 13 | svn commit -m "prepare for the release of rrdtool-$VERSION" 14 | mkdir /tmp/rrdtool-$$ 15 | OPWD=`pwd` 16 | cd /tmp/rrdtool-$$ 17 | svn checkout svn://svn.oetiker.ch/rrdtool/branches/1.2/program . 18 | svn log --stop-on-copy --xml --verbose svn://svn.oetiker.ch/rrdtool/branches/1.2/program | \ 19 | xsltproc --stringparam strip-prefix branches/1.2/program $OPWD/svn2cl.xsl - >CHANGES 20 | sh MakeMakefile 21 | PKG_CONFIG_PATH=/usr/pack/rrdtool-1.2svn-to/i686-debian-linux3.1/lib/pkgconfig/ 22 | export PKG_CONFIG_PATH 23 | ./configure 24 | make dist 25 | # do a test build 26 | tar zxvf rrdtool*.tar.gz 27 | cd rrdtool-$VERSION 28 | ./configure 29 | make 30 | src/rrdtool 31 | cd .. 32 | scp CHANGES rrdtool*.tar.gz oposs@james:public_html/rrdtool/pub/ 33 | ssh oposs@james "cd public_html/rrdtool/pub/;rm rrdtool.tar.gz;ln -s rrdtool-$VERSION.tar.gz rrdtool.tar.gz" 34 | cd .. 35 | rm -rf rrdtool-$$ 36 | svn copy -m "tagging version $VERSION" svn://svn.oetiker.ch/rrdtool/branches/1.2/program svn://svn.oetiker.ch/rrdtool/tags/$VERSION 37 | 38 | -------------------------------------------------------------------------------- /win32/config.h: -------------------------------------------------------------------------------- 1 | /* config.h.msvc. Hand-tweaked config.h for MSVC compiler. */ 2 | #ifndef CONFIG_H 3 | #define CONFIG_H 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | /* realloc does not support NULL as argument */ 11 | 12 | #define HAVE_STRFTIME 1 13 | #define HAVE_TIME_H 1 14 | #define HAVE_LOCALE_H 1 15 | #define HAVE_TZSET 1 16 | #define HAVE_SETLOCALE 1 17 | #define HAVE_MATH_H 1 18 | #define HAVE_FLOAT_H 1 19 | #define HAVE_MEMMOVE 1 20 | #define HAVE_MALLOC_H 1 21 | #define HAVE_MKTIME 1 22 | #define HAVE_STRFTIME 1 23 | #define HAVE_STRING_H 1 24 | #define HAVE_STDLIB_H 1 25 | #define HAVE_VSNPRINTF 1 26 | #define HAVE_SYS_TYPES_H 1 27 | #define HAVE_SYS_STAT_H 1 28 | 29 | /* Define to 1 if you have the ANSI C header files. */ 30 | #define STDC_HEADERS 1 31 | 32 | #define NUMVERS 1.4030 33 | #define PACKAGE_NAME "rrdtool" 34 | #define PACKAGE_VERSION "1.4.3" 35 | #define PACKAGE_STRING PACKAGE_NAME " " PACKAGE_VERSION 36 | 37 | #define isinf(a) (_fpclass(a) == _FPCLASS_NINF || _fpclass(a) == _FPCLASS_PINF) 38 | #define isnan _isnan 39 | #define finite _finite 40 | #define snprintf _snprintf 41 | //#define vsnprintf _vsnprintf 42 | //#define strftime strftime_ 43 | 44 | #define NO_NULL_REALLOC 1 45 | #if NO_NULL_REALLOC 46 | # define rrd_realloc(a,b) ( (a) == NULL ? malloc( (b) ) : realloc( (a) , (b) )) 47 | #else 48 | # define rrd_realloc(a,b) realloc((a), (b)) 49 | #endif 50 | 51 | /* Vertical label angle: 90.0 (default) or 270.0 */ 52 | #define RRDGRAPH_YLEGEND_ANGLE 90.0 53 | 54 | #define RRD_DEFAULT_FONT "Courier" 55 | 56 | /* #define DEBUG 1 */ 57 | 58 | __inline int round(double a){int x = (a + 0.5); return x;} 59 | 60 | #endif /* CONFIG_H */ 61 | -------------------------------------------------------------------------------- /win32/rrd_config.h.msvc: -------------------------------------------------------------------------------- 1 | /* config.h.msvc. Hand-tweaked config.h for MSVC compiler. */ 2 | #ifndef CONFIG_H 3 | #define CONFIG_H 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | /* realloc does not support NULL as argument */ 11 | 12 | #define HAVE_STRFTIME 1 13 | #define HAVE_TIME_H 1 14 | #define HAVE_LOCALE_H 1 15 | #define HAVE_TZSET 1 16 | #define HAVE_SETLOCALE 1 17 | #define HAVE_MATH_H 1 18 | #define HAVE_FLOAT_H 1 19 | #define HAVE_MEMMOVE 1 20 | #define HAVE_MALLOC_H 1 21 | #define HAVE_MKTIME 1 22 | #define HAVE_STRFTIME 1 23 | #define HAVE_STRING_H 1 24 | #define HAVE_STDLIB_H 1 25 | #define HAVE_VSNPRINTF 1 26 | #define HAVE_SYS_TYPES_H 1 27 | #define HAVE_SYS_STAT_H 1 28 | 29 | /* Define to 1 if you have the ANSI C header files. */ 30 | #define STDC_HEADERS 1 31 | 32 | #define NUMVERS 1.4030 33 | #define PACKAGE_NAME "rrdtool" 34 | #define PACKAGE_VERSION "1.4.3" 35 | #define PACKAGE_STRING PACKAGE_NAME " " PACKAGE_VERSION 36 | 37 | #define isinf(a) (_fpclass(a) == _FPCLASS_NINF || _fpclass(a) == _FPCLASS_PINF) 38 | #define isnan _isnan 39 | #define finite _finite 40 | #define snprintf _snprintf 41 | //#define vsnprintf _vsnprintf 42 | //#define strftime strftime_ 43 | 44 | #define NO_NULL_REALLOC 1 45 | #if NO_NULL_REALLOC 46 | # define rrd_realloc(a,b) ( (a) == NULL ? malloc( (b) ) : realloc( (a) , (b) )) 47 | #else 48 | # define rrd_realloc(a,b) realloc((a), (b)) 49 | #endif 50 | 51 | /* Vertical label angle: 90.0 (default) or 270.0 */ 52 | #define RRDGRAPH_YLEGEND_ANGLE 90.0 53 | 54 | #define RRD_DEFAULT_FONT "Courier" 55 | 56 | /* #define DEBUG 1 */ 57 | 58 | __inline int round(double a){int x = (a + 0.5); return x;} 59 | 60 | #endif /* CONFIG_H */ 61 | -------------------------------------------------------------------------------- /bindings/perl-shared/Makefile.PL: -------------------------------------------------------------------------------- 1 | use ExtUtils::MakeMaker; 2 | use Config; 3 | # See lib/ExtUtils/MakeMaker.pm for details of how to influence 4 | # the contents of the Makefile that is written. 5 | 6 | # if the last argument when calling Makefile.PL is RPATH=/... and ... is the 7 | # path to librrd.so then the Makefile will be written such that RRDs.so knows 8 | # where to find librrd.so later on ... 9 | my $R=""; 10 | if ($ARGV[-1] =~ /RPATH=(\S+)/){ 11 | pop @ARGV; 12 | my $rp = $1; 13 | for ($^O){ 14 | /linux/ && do{ $R = "-Wl,--rpath -Wl,$rp"}; 15 | /hpux/ && do{ $R = "+b$rp"}; 16 | /solaris/ && do{ $R = "-R$rp"}; 17 | /bsd/ && do{ $R = "-R$rp"}; 18 | /aix/ && do{ $R = "-Wl,-blibpath:$rp"}; 19 | } 20 | } 21 | 22 | # darwin works without this because librrd contains its 23 | # install_name which will includes the final location of the 24 | # library after it is installed. This install_name gets transfered 25 | # to the perl shared object. 26 | 27 | my $librrd; 28 | if ($^O eq 'darwin'){ 29 | $librrd = '-lrrd'; 30 | } 31 | else { 32 | $librrd = "-L../../src/.libs/ $R -lrrd"; 33 | } 34 | 35 | WriteMakefile( 36 | 'NAME' => 'RRDs', 37 | 'VERSION_FROM' => 'RRDs.pm', # finds $VERSION 38 | 'DEFINE' => "-DPERLPATCHLEVEL=$Config{PATCHLEVEL}", 39 | 'INC' => '-I../../src', 40 | # Perl will figure out which one is valid 41 | #'dynamic_lib' => {'OTHERLDFLAGS' => "$librrd -lm"}, 42 | 'depend' => {'RRDs.c' => "../../src/librrd.la"}, 43 | 'LDFROM' => '$(OBJECT) '.$librrd, 44 | 'realclean' => {FILES => 't/demo?.rrd t/demo?.png' }, 45 | ($^O eq 'darwin') ? ( 'LDDLFLAGS' => "-L../../src/.libs/ $Config{lddlflags}" ) : () 46 | ); 47 | 48 | -------------------------------------------------------------------------------- /rrdtool-1.4-release: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | VERSION=`perl -n -e 'm/\QAC_INIT([rrdtool],[\E(.+?)\Q])\E/ && print $1' configure.ac` 4 | PERLVERS=`perl -n -e 'm/NUMVERS=(\d+\.\d+)/ && print $1' configure.ac` 5 | set -x 6 | perl -i -p -e 's/^\$VERSION.+/\$VERSION='$PERLVERS';/' bindings/perl-*/*.pm 7 | perl -i -p -e 's/RRDtool 1\S+/RRDtool '$VERSION'/ && s/Copyright.+?Oetiker.+\d{4}/Copyright by Tobi Oetiker, 1997-2010/' src/*.h src/*.c 8 | perl -i -p -e 's/^Version:.+/Version: '$VERSION'/' rrdtool.spec 9 | perl -i -p -e 's/rrdtool-[\.\d]+\d(pre\d+)?(rc\d+)?/rrdtool-'$VERSION'/g' doc/rrdbuild.pod 10 | svn diff 11 | echo "Tagging and releasing rrdtool $VERSION ($PERLVERS). Press any Key to continue." 12 | read somekey 13 | svn commit -m "prepare for the release of rrdtool-$VERSION" 14 | OPWD=`pwd` 15 | cd /tmp 16 | svn export svn://svn.oetiker.ch/rrdtool/trunk/program rrdtool-$$ 17 | cd rrdtool-$$ 18 | #svn log --stop-on-copy --xml --verbose svn://svn.oetiker.ch/rrdtool/trunk | \ 19 | # xsltproc --stringparam strip-prefix trunk/program $OPWD/svn2cl.xsl - >CHANGES 20 | sh MakeMakefile 21 | #PKG_CONFIG_PATH=/usr/pack/rrdtool-1.3svn-to/i686-debian-linux3.1/lib/pkgconfig/ 22 | #export PKG_CONFIG_PATH 23 | ./configure --enable-maintainer-mode 24 | make dist 25 | # do a test build 26 | tar zxvf rrdtool*.tar.gz 27 | cd rrdtool-$VERSION 28 | ./configure 29 | make 30 | src/rrdtool 31 | cd .. 32 | echo READY TO DIST ... press ENTER 33 | read x 34 | 35 | scp CHANGES rrdtool*.tar.gz oposs@james:public_html/rrdtool/pub 36 | ssh oposs@james "cd public_html/rrdtool/pub/;rm rrdtool.tar.gz;ln -s rrdtool-$VERSION.tar.gz rrdtool.tar.gz" 37 | cd .. 38 | rm -rf rrdtool-$$ 39 | svn copy -m "tagging version $VERSION" svn://svn.oetiker.ch/rrdtool/trunk/program svn://svn.oetiker.ch/rrdtool/tags/$VERSION 40 | 41 | -------------------------------------------------------------------------------- /src/rrd_datalang.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * RRDtool 1.4.3 Copyright by Tobi Oetiker, 1997-2010 3 | ***************************************************************************** 4 | * rrd_datalang A system for passing named and typed parameters between 5 | * the different parts of rrdtool 6 | * 7 | * In rrdtool thre are a number of places where large and complex 8 | * data structures have to be passed from one function to another 9 | * eg when rrd_info returns its findings, but also when a function like 10 | * rrd_graph get called. 11 | * 12 | * At the moment function calling is done with an argc/argv type interface 13 | * it's special property is that all data is passed as strings, which can lead 14 | * to unnecessary conversions being performed when rrdtool functions are called 15 | * from a typed language 16 | * 17 | * Data returns from functions is not standardized at all, which is 18 | * efficient in the sense that the data return interface can be tailord to 19 | * the specific needs of the function at hand, but it also leads to 20 | * increassed probability for implementation errors as things have to be 21 | * reinvented for each function. Also adding new functions into all the 22 | * language bindings is quite cumbersom. 23 | * 24 | * Therefore I want to develop a standardized interface for passing named 25 | * and typed data into functions and for returning data from functions to 26 | * their callers. I am thinking about working of the code in rrd_info.c ... 27 | * 28 | * Does anyone have experiance in this field or any pointers to read up on 29 | * related work ? Or maybe even an existing library for this ? 30 | * 31 | * Cheers 32 | * tobi / 2001-03-10 33 | * 34 | *****************************************************************************/ 35 | -------------------------------------------------------------------------------- /src/win32comp.c: -------------------------------------------------------------------------------- 1 | /* compatibility routines, non reentrant .... */ 2 | 3 | #include 4 | #include 5 | 6 | struct tm *localtime_r( 7 | const time_t *t, 8 | struct tm *r) 9 | { 10 | struct tm *temp; 11 | 12 | temp = localtime(t); 13 | memcpy(r, temp, sizeof(struct tm)); 14 | return (r); 15 | } 16 | 17 | struct tm *gmtime_r( 18 | const time_t *t, 19 | struct tm *r) 20 | { 21 | struct tm *temp; 22 | 23 | temp = gmtime(t); 24 | memcpy(r, temp, sizeof(struct tm)); 25 | return r; 26 | } 27 | 28 | char *ctime_r( 29 | const time_t *t, 30 | char *buf) 31 | { 32 | char *temp; 33 | 34 | temp = asctime(localtime(t)); 35 | strcpy(buf, temp); 36 | return (buf); 37 | } 38 | 39 | /* 40 | s 41 | Points to the string from which to extract tokens. 42 | 43 | delim 44 | Points to a null-terminated set of delimiter characters. 45 | 46 | save_ptr 47 | Is a value-return parameter used by strtok_r() to record its progress through s1. 48 | */ 49 | 50 | 51 | char *strtok_r( 52 | char *s, 53 | const char *delim, 54 | char **save_ptr) 55 | { 56 | char *token; 57 | 58 | if (s == NULL) 59 | s = *save_ptr; 60 | 61 | /* Scan leading delimiters. */ 62 | s += strspn(s, delim); 63 | if (*s == '\0') { 64 | *save_ptr = s; 65 | return NULL; 66 | } 67 | 68 | /* Find the end of the token. */ 69 | token = s; 70 | s = strpbrk(token, delim); 71 | if (s == NULL) { 72 | /* This token finishes the string. */ 73 | *save_ptr = token; 74 | while (**save_ptr != '\0') 75 | (*save_ptr)++; 76 | } else { 77 | /* Terminate the token and make *SAVE_PTR point past it. */ 78 | *s = '\0'; 79 | *save_ptr = s + 1; 80 | } 81 | return token; 82 | } 83 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id$ 2 | 3 | ## Process this file with automake to produce Makefile.in 4 | RSYNC = rsync --rsh=ssh 5 | 6 | # build the following subdirectories 7 | 8 | SUBDIRS = po src examples doc bindings 9 | 10 | # the following files are not mentioned in any other Makefile 11 | EXTRA_DIST = COPYRIGHT CHANGES WIN32-BUILD-TIPS.txt TODO CONTRIBUTORS THREADS \ 12 | rrdtool.spec favicon.ico win32/Makefile win32/config.h autogen.sh \ 13 | win32/rrd.dsp win32/rrd.sln win32/rrd.vcproj libtool \ 14 | win32/rrd_config.h.msvc win32/rrdlib.vcproj win32/rrdtool.dsp \ 15 | win32/rrdtool.dsw win32/rrdtool.vcproj netware/Makefile \ 16 | etc/rrdcached-default etc/rrdcached-init 17 | 18 | 19 | 20 | CLEANFILES = config.cache 21 | 22 | # use relaxed rules when building dists 23 | AUTOMAKE_OPTIONS= foreign 24 | 25 | # where we keep local rules for automake 26 | ACLOCAL_AMFLAGS=-I m4 27 | ACLOCAL_M4= $(top_srcdir)/aclocal.m4 28 | #AUTOHEADER = @AUTOHEADER@ --localdir=$(top_srcdir)/config 29 | #AUTOCONF = @AUTOCONF@ --localdir=$(top_srcdir)/config 30 | 31 | # $(RSYNC) CHANGES archive/$(PACKAGE)-$(VERSION).tar.gz tobi@ipn.caida.org:/ipn/web/Tools/RRDtool/pub/ 32 | 33 | site-perl-inst: site-perl-install 34 | 35 | site-perl-install: all bindings/perl-piped/Makefile bindings/perl-shared/Makefile 36 | cd bindings/perl-piped && $(MAKE) install 37 | cd bindings/perl-shared && $(MAKE) install 38 | 39 | site-tcl-install: all 40 | cd bindings/tcl && $(MAKE) tcl-install 41 | 42 | site-python-install: all 43 | cd bindings/python && $(PYTHON) setup.py install $(if $(DESTDIR),--root=$(DESTDIR)) 44 | 45 | # find . -name "*.c" -or -name "*.h" | xargs perl -0777 -n -e 'while (s/typedef\s+(?:unsigned\s+|signed\s+|unival\s+)?\S+\s+\*?([^{}\s;(]+)//){print "-T$1\n"}' 46 | indent: 47 | find ./ -name "*.[ch]" | xargs indent 48 | 49 | ##END## 50 | -------------------------------------------------------------------------------- /bindings/tcl/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | EXTRA_DIST = README tclrrd.c 3 | 4 | VERSION = @VERSION@ 5 | 6 | AM_CFLAGS = @CFLAGS@ 7 | ### no including this by default @WERROR@ 8 | 9 | TCL_PREFIX = @TCL_PREFIX@ 10 | TCL_SHLIB_LD = @TCL_SHLIB_LD@ 11 | TCL_SHLIB_CFLAGS = @TCL_SHLIB_CFLAGS@ 12 | TCL_SHLIB_SUFFIX = @TCL_SHLIB_SUFFIX@ 13 | TCL_PACKAGE_PATH = @TCL_PACKAGE_PATH@ 14 | TCL_LD_SEARCH_FLAGS = @TCL_LD_SEARCH_FLAGS@ 15 | TCL_STUB_LIB_SPEC = @TCL_STUB_LIB_SPEC@ 16 | TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@ 17 | 18 | CLEANFILES = tclrrd.o tclrrd.so 19 | 20 | SRC_DIR = $(top_srcdir)/src 21 | AM_CPPFLAGS = $(TCL_INCLUDE_SPEC) -I$(SRC_DIR) -DUSE_TCL_STUBS 22 | LIBDIRS = -L$(top_builddir)/src/.libs -L$(top_builddir)/src -L$(libdir) 23 | LIB_RUNTIME_DIR = $(libdir) 24 | 25 | if BUILD_TCL_SITE 26 | tclpkgdir = @TCL_PACKAGE_DIR@ 27 | tclpkg_DATA = pkgIndex.tcl 28 | tclpkg_SCRIPTS = ifOctets.tcl 29 | else 30 | pkglib_DATA = pkgIndex.tcl 31 | pkglib_SCRIPTS = ifOctets.tcl 32 | endif 33 | 34 | # Automake doen't like `tclrrd$(VERSION)$(TCL_SHLIB_SUFFIX)' as 35 | # library name. So we build and install this library `by hand'. 36 | # 37 | # We do, however, specify a lib_LIBRARIES target such that 38 | # automake creates the directory (if neecessary). 39 | # 40 | TCL_RRD_LIB = tclrrd$(VERSION)$(TCL_SHLIB_SUFFIX) 41 | 42 | lib_LIBRARIES = 43 | 44 | all-local: $(TCL_RRD_LIB) 45 | 46 | $(TCL_RRD_LIB): tclrrd.o 47 | $(TCL_SHLIB_LD) $(TCL_LD_SEARCH_FLAGS) $(LIBDIRS) $< -o $@ -lrrd_th -lm $(TCL_STUB_LIB_SPEC) $(LDFLAGS) $(LIBS) 48 | 49 | tclrrd.o: tclrrd.c 50 | $(CC) $(AM_CFLAGS) $(CFLAGS) $(TCL_SHLIB_CFLAGS) $(AM_CPPFLAGS) -c tclrrd.c -DVERSION=\"$(VERSION)\" 51 | 52 | pkgIndex.tcl: 53 | echo "package ifneeded Rrd $(VERSION) \"load $(libdir)/tclrrd$(VERSION)[info sharedlibextension]\"" > $@ 54 | 55 | install-exec-local: $(TCL_RRD_LIB) 56 | @$(NORMAL_INSTALL) 57 | $(INSTALL_PROGRAM) $(TCL_RRD_LIB) $(DESTDIR)$(libdir)/$(TCL_RRD_LIB) 58 | 59 | -------------------------------------------------------------------------------- /.indent.pro: -------------------------------------------------------------------------------- 1 | --blank-lines-after-declarations 2 | --blank-lines-after-procedures 3 | --break-before-boolean-operator 4 | --break-function-decl-args 5 | --no-blank-lines-after-commas 6 | --braces-on-if-line 7 | --braces-on-struct-decl-line 8 | --comment-indentation25 9 | --declaration-comment-column25 10 | --no-comment-delimiters-on-blank-lines 11 | --cuddle-else 12 | --continuation-indentation4 13 | --case-indentation0 14 | --else-endif-column33 15 | --space-after-cast 16 | --line-comments-indentation0 17 | --declaration-indentation10 18 | --dont-format-first-column-comments 19 | --dont-format-comments 20 | --honour-newlines 21 | --indent-level4 22 | /* changed from 0 to 4 */ 23 | --parameter-indentation4 24 | --line-length78 /* changed from 75 */ 25 | --continue-at-parentheses 26 | --no-space-after-function-call-names 27 | --dont-break-procedure-type 28 | --dont-star-comments 29 | --leave-optional-blank-lines 30 | --dont-space-special-semicolon 31 | --tab-size4 32 | /* additions by Mark */ 33 | --case-brace-indentation0 34 | --leave-preprocessor-space 35 | --no-tabs 36 | -TFIFOqueue 37 | -TFnv32_t 38 | -TTcl_Interp 39 | -T_ArtRgbaSVPAlphaData 40 | -Tafm_fontinfo 41 | -Tafm_sint16 42 | -Tafm_sint8 43 | -Tafm_uint16 44 | -Tafm_uint8 45 | -Tafm_unicode 46 | -Tcdp_prep_t 47 | -Tcgi_s 48 | -Tds_def_t 49 | -Teps_font 50 | -Teps_state 51 | -Tgfx_canvas_t 52 | -Tgfx_char_s 53 | -Tgfx_color_t 54 | -Tgfx_node_t 55 | -Tgfx_string_s 56 | -Tgraph_desc_t 57 | -Timage_desc_t 58 | -Tinfo_t 59 | -Tinfoval 60 | -Tlive_head_t 61 | -Toff_t 62 | -Told_afm_fontinfo 63 | -Tpdf_buffer 64 | -Tpdf_font 65 | -Tpdf_point 66 | -Tpdf_state 67 | -Tpdp_prep_t 68 | -Trpn_cdefds_t 69 | -Trpnp_t 70 | -Trpnstack_t 71 | -Trra_def_t 72 | -Trra_ptr_t 73 | -Trrd_file_t 74 | -Trrd_t 75 | -Trrd_value_t 76 | -Tstat_head_t 77 | -Tstring_arr_t 78 | -Tsvg_dash 79 | -Ttext_prop_t 80 | -Ttime_t 81 | -Ttm 82 | -Tunival 83 | -Tva_list 84 | -Tvar_s 85 | -Tvdef_t 86 | -Txlab_t 87 | -Tygrid_scale_t 88 | -Tylab_t 89 | -------------------------------------------------------------------------------- /po/Makevars: -------------------------------------------------------------------------------- 1 | # Makefile variables for PO directory in any package using GNU gettext. 2 | 3 | # Usually the message domain is the same as the package name. 4 | DOMAIN = $(PACKAGE) 5 | 6 | # These two variables depend on the location of this directory. 7 | subdir = po 8 | top_builddir = .. 9 | 10 | # These options get passed to xgettext. 11 | XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ 12 | 13 | # This is the copyright holder that gets inserted into the header of the 14 | # $(DOMAIN).pot file. Set this to the copyright holder of the surrounding 15 | # package. (Note that the msgstr strings, extracted from the package's 16 | # sources, belong to the copyright holder of the package.) Translators are 17 | # expected to transfer the copyright for their translations to this person 18 | # or entity, or to disclaim their copyright. The empty string stands for 19 | # the public domain; in this case the translators are expected to disclaim 20 | # their copyright. 21 | COPYRIGHT_HOLDER = Tobias Oetiker 22 | 23 | # This is the email address or URL to which the translators shall report 24 | # bugs in the untranslated strings: 25 | # - Strings which are not entire sentences, see the maintainer guidelines 26 | # in the GNU gettext documentation, section 'Preparing Strings'. 27 | # - Strings which use unclear terms or require additional context to be 28 | # understood. 29 | # - Strings which make invalid assumptions about notation of date, time or 30 | # money. 31 | # - Pluralisation problems. 32 | # - Incorrect English spelling. 33 | # - Incorrect formatting. 34 | # It can be your email address, or a mailing list address where translators 35 | # can write to without being subscribed, or the URL of a web page through 36 | # which the translators can contact you. 37 | MSGID_BUGS_ADDRESS = http://oss.oetiker.ch/rrdtool-trac/newticket 38 | 39 | # This is the list of locale categories, beyond LC_MESSAGES, for which the 40 | # message catalogs shall be used. It is usually empty. 41 | EXTRA_LOCALE_CATEGORIES = 42 | -------------------------------------------------------------------------------- /bindings/python/setup.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | # 3 | # setup.py 4 | # 5 | # py-rrdtool distutil setup 6 | # 7 | # Author : Hye-Shik Chang 8 | # Date : $Date: 2003/02/14 02:38:16 $ 9 | # Created : 24 May 2002 10 | # 11 | # $Revision: 1.7 $ 12 | # 13 | # ========================================================================== 14 | # This file is part of py-rrdtool. 15 | # 16 | # py-rrdtool is free software; you can redistribute it and/or modify 17 | # it under the terms of the GNU Lesser General Public License as published 18 | # by the Free Software Foundation; either version 2 of the License, or 19 | # (at your option) any later version. 20 | # 21 | # py-rrdtool is distributed in the hope that it will be useful, 22 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | # GNU Lesser General Public License for more details. 25 | # 26 | # You should have received a copy of the GNU Lesser General Public License 27 | # along with Foobar; if not, write to the Free Software 28 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 29 | # 30 | 31 | from distutils.core import setup, Extension 32 | import sys, os 33 | 34 | RRDBASE = os.environ.get('LOCALBASE', '../../src') 35 | library_dir = os.environ.get('BUILDLIBDIR', os.path.join(RRDBASE, '.libs')) 36 | include_dir = os.environ.get('INCDIR', RRDBASE) 37 | 38 | setup(name = "py-rrdtool", 39 | version = "0.2.1", 40 | description = "Python Interface to RRDTool", 41 | author = "Hye-Shik Chang", 42 | author_email = "perky@fallin.lv", 43 | license = "LGPL", 44 | url = "http://oss.oetiker.ch/rrdtool", 45 | #packages = ['rrdtool'], 46 | ext_modules = [ 47 | Extension( 48 | "rrdtoolmodule", 49 | ["rrdtoolmodule.c"], 50 | libraries=['rrd'], 51 | library_dirs=[library_dir], 52 | include_dirs=[include_dir], 53 | ) 54 | ] 55 | ) 56 | -------------------------------------------------------------------------------- /src/pngsize.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * RRDtool 1.4.3 Copyright by Tobi Oetiker, 1997-2010 3 | ***************************************************************************** 4 | * pngsize.c determine the size of a PNG image 5 | *****************************************************************************/ 6 | 7 | #include 8 | #include "rrd_tool.h" 9 | 10 | int PngSize( 11 | FILE * fd, 12 | long *width, 13 | long *height) 14 | { 15 | png_structp png_read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 16 | (png_voidp) NULL, 17 | /* we would need to point to error handlers 18 | here to do it properly */ 19 | (png_error_ptr) NULL, 20 | (png_error_ptr) NULL); 21 | 22 | png_infop info_ptr = png_create_info_struct(png_read_ptr); 23 | 24 | (*width) = 0; 25 | (*height) = 0; 26 | 27 | /* this is to make compile on aix work since they seem to define jmpbuf 28 | to be _jmpbuf which breaks compilation */ 29 | 30 | #ifndef png_jmpbuf 31 | #ifdef PNG_SETJMP_SUPPORTED 32 | # define png_jmpbuf(png_ptr) ((png_ptr)->PNG_jmpbuf) 33 | #else 34 | #ifdef jmpbuf 35 | #undef jmpbuf 36 | #endif 37 | # define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) 38 | #endif 39 | #endif 40 | 41 | if (setjmp(png_jmpbuf(png_read_ptr))) { 42 | png_destroy_read_struct(&png_read_ptr, &info_ptr, (png_infopp) NULL); 43 | return 0; 44 | } 45 | 46 | png_init_io(png_read_ptr, fd); 47 | png_read_info(png_read_ptr, info_ptr); 48 | (*width) = png_get_image_width(png_read_ptr, info_ptr); 49 | (*height) = png_get_image_height(png_read_ptr, info_ptr); 50 | 51 | png_destroy_read_struct(&png_read_ptr, &info_ptr, NULL); 52 | if (*width > 0 && *height > 0) 53 | return 1; 54 | else 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /src/rrd_hw.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * RRDtool 1.4.3 Copyright by Tobi Oetiker, 1997-2010 3 | ***************************************************************************** 4 | * rrd_hw.h : Support for Holt-Winters Smoothing/ Aberrant Behavior Detection 5 | *****************************************************************************/ 6 | 7 | /* functions implemented in rrd_hw.c */ 8 | int update_aberrant_CF( 9 | rrd_t *rrd, 10 | rrd_value_t pdp_val, 11 | enum cf_en current_cf, 12 | unsigned long cdp_idx, 13 | unsigned long rra_idx, 14 | unsigned long ds_idx, 15 | unsigned short CDP_scratch_idx, 16 | rrd_value_t *seasonal_coef); 17 | int create_hw_contingent_rras( 18 | rrd_t *rrd, 19 | unsigned short period, 20 | unsigned long hashed_name); 21 | int lookup_seasonal( 22 | rrd_t *rrd, 23 | unsigned long rra_idx, 24 | unsigned long rra_start, 25 | rrd_file_t *rrd_file, 26 | unsigned long offset, 27 | rrd_value_t **seasonal_coef); 28 | void erase_violations( 29 | rrd_t *rrd, 30 | unsigned long cdp_idx, 31 | unsigned long rra_idx); 32 | int apply_smoother( 33 | rrd_t *rrd, 34 | unsigned long rra_idx, 35 | unsigned long rra_start, 36 | rrd_file_t *rrd_file); 37 | void reset_aberrant_coefficients( 38 | rrd_t *rrd, 39 | rrd_file_t *rrd_file, 40 | unsigned long ds_idx); 41 | void init_hwpredict_cdp( 42 | cdp_prep_t *); 43 | void init_seasonal_cdp( 44 | cdp_prep_t *); 45 | 46 | #define BURNIN_CYCLES 3 47 | 48 | /* a standard fixed-capacity FIFO queue implementation */ 49 | typedef struct FIFOqueue { 50 | rrd_value_t *queue; 51 | int capacity, head, tail; 52 | } FIFOqueue; 53 | 54 | int queue_alloc( 55 | FIFOqueue **q, 56 | int capacity); 57 | void queue_dealloc( 58 | FIFOqueue *q); 59 | void queue_push( 60 | FIFOqueue *q, 61 | rrd_value_t value); 62 | int queue_isempty( 63 | FIFOqueue *q); 64 | rrd_value_t queue_pop( 65 | FIFOqueue *q); 66 | -------------------------------------------------------------------------------- /examples/rrdcached/RRDCached.pm: -------------------------------------------------------------------------------- 1 | 2 | use strict; 3 | use warnings; 4 | 5 | package RRDCached; 6 | 7 | =head1 RRDCached 8 | 9 | This module implements the B client protocol for bulk updates. 10 | 11 | =head1 SYNOPSIS 12 | 13 | my $cache = RRDCached->new('unix:/var/run/rrdcached.sock') 14 | or die "Cannot connect to RRDCached"; 15 | 16 | $cache->update('file1.rrd', 'N:10:2:78'); 17 | $cache->update('file2.rrd', '1222973760:30:0:9', 'N:68:1:55'); 18 | ... 19 | 20 | $cache->done(); 21 | 22 | =cut 23 | 24 | use IO::Socket; 25 | 26 | ################################################################# 27 | 28 | sub new { 29 | my ($class, $daemon) = @_; 30 | my $this = {}; 31 | 32 | $daemon ||= $ENV{RRDCACHED_ADDRESS}; 33 | defined $daemon or return undef; 34 | 35 | my $sock_family = "INET"; 36 | 37 | if ($daemon =~ m{^unix: | ^/ }x) 38 | { 39 | $sock_family = "UNIX"; 40 | $daemon =~ s/^unix://; 41 | } 42 | 43 | my $sock = "IO::Socket::$sock_family"->new($daemon) 44 | or die "Cannot connect to daemon"; 45 | 46 | $sock->printflush("BATCH\n"); 47 | 48 | my $go = $sock->getline; 49 | warn "We didn't get go-ahead from rrdcached" unless $go =~ /^0/; 50 | 51 | $sock->autoflush(0); 52 | 53 | bless { sock => $sock, 54 | daemon => $daemon, 55 | }, $class; 56 | } 57 | 58 | sub update { 59 | my $this = shift; 60 | my $file = shift; 61 | ## @updates = @_; 62 | 63 | @_ or warn "No updates for $file!"; 64 | 65 | ## rrdcached doesn't handle N: timestamps 66 | my $now = time(); 67 | s/^N(?=:)/$now/ for (@_); 68 | 69 | $this->{sock}->print("update $file @_\n"); 70 | } 71 | 72 | sub done { 73 | my ($this) = @_; 74 | 75 | my $sock = delete $this->{sock}; 76 | 77 | $sock->printflush(".\n"); 78 | my $errs = $sock->getline; 79 | 80 | my ($num_err) = $errs =~ /^(\d+)/; 81 | return unless $num_err; 82 | 83 | $sock->getline for (1..$num_err); 84 | 85 | $sock->close; 86 | } 87 | 88 | ################################################################# 89 | 90 | 1; 91 | -------------------------------------------------------------------------------- /bindings/ruby/test.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # $Id: test.rb,v 1.2 2002/10/22 17:34:00 miles Exp $ 3 | # Driver does not carry cash. 4 | 5 | $: << '/scratch/rrd12build/lib/ruby/1.8/i386-linux/' 6 | 7 | require "RRD" 8 | 9 | name = "test" 10 | rrd = "#{name}.rrd" 11 | start_time = Time.now.to_i 12 | end_time = start_time.to_i + 300 * 300 13 | 14 | puts "creating #{rrd}" 15 | RRD.create( 16 | rrd, 17 | "--start", "#{start_time - 1}", 18 | "--step", "300", 19 | "DS:a:GAUGE:600:U:U", 20 | "DS:b:GAUGE:600:U:U", 21 | "RRA:AVERAGE:0.5:1:300") 22 | puts 23 | 24 | puts "updating #{rrd}" 25 | start_time.step(end_time, 300) { |i| 26 | RRD.update(rrd, "#{i}:#{rand(100)}:#{Math.sin(i / 800) * 50 + 50}") 27 | } 28 | puts 29 | 30 | puts "fetching data from #{rrd}" 31 | (fstart, fend, data) = RRD.fetch(rrd, "--start", start_time.to_s, "--end", end_time.to_s, "AVERAGE") 32 | puts "got #{data.length} data points from #{fstart} to #{fend}" 33 | puts 34 | 35 | puts "generating graph #{name}.png" 36 | RRD.graph( 37 | "#{name}.png", 38 | "--title", " RubyRRD Demo", 39 | "--start", "#{start_time+3600}", 40 | "--end", "start + 1000 min", 41 | "--interlace", 42 | "--imgformat", "PNG", 43 | "--width=450", 44 | "DEF:a=#{rrd}:a:AVERAGE", 45 | "DEF:b=#{rrd}:b:AVERAGE", 46 | "CDEF:line=TIME,2400,%,300,LT,a,UNKN,IF", 47 | "AREA:b#00b6e4:beta", 48 | "AREA:line#0022e9:alpha", 49 | "LINE3:line#ff0000") 50 | puts 51 | 52 | # last method test 53 | if end_time != RRD.last("#{rrd}").to_i 54 | puts "last method expects #{Time.at(end_time)}." 55 | puts " But #{RRD.last("#{rrd}")} returns." 56 | end 57 | puts 58 | 59 | # xport method test 60 | puts "xporting data from #{rrd}" 61 | (fstart,fend,step,col,legend,data)=RRD.xport( 62 | "--start", start_time.to_s, 63 | "--end", (start_time + 300 * 300).to_s, 64 | "--step", 10.to_s, 65 | "DEF:A=#{rrd}:a:AVERAGE", 66 | "DEF:B=#{rrd}:b:AVERAGE", 67 | "XPORT:A:a", 68 | "XPORT:B:b") 69 | puts "Xported #{col} columns(#{legend.join(", ")}) with #{data.length} rows from #{fstart} to #{fend} and step #{step}\n" 70 | 71 | print "This script has created #{name}.png in the current directory\n"; 72 | print "This demonstrates the use of the TIME and % RPN operators\n"; 73 | -------------------------------------------------------------------------------- /win32/rrd.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual Studio 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rrdlib", "rrdlib.vcproj", "{CC158E1D-1364-43CA-9B2D-4AF54225C7CA}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rrdtool", "rrdtool.vcproj", "{11CD05F8-E5E1-476E-A75F-A112655D4E94}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {CC158E1D-1364-43CA-9B2D-4AF54225C7CA} = {CC158E1D-1364-43CA-9B2D-4AF54225C7CA} 9 | EndProjectSection 10 | EndProject 11 | Global 12 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 13 | Debug|Win32 = Debug|Win32 14 | DebugDLL|Win32 = DebugDLL|Win32 15 | Release|Win32 = Release|Win32 16 | Static Debug|Win32 = Static Debug|Win32 17 | EndGlobalSection 18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 19 | {CC158E1D-1364-43CA-9B2D-4AF54225C7CA}.Debug|Win32.ActiveCfg = Debug|Win32 20 | {CC158E1D-1364-43CA-9B2D-4AF54225C7CA}.Debug|Win32.Build.0 = Debug|Win32 21 | {CC158E1D-1364-43CA-9B2D-4AF54225C7CA}.DebugDLL|Win32.ActiveCfg = DebugDLL|Win32 22 | {CC158E1D-1364-43CA-9B2D-4AF54225C7CA}.DebugDLL|Win32.Build.0 = DebugDLL|Win32 23 | {CC158E1D-1364-43CA-9B2D-4AF54225C7CA}.Release|Win32.ActiveCfg = Release|Win32 24 | {CC158E1D-1364-43CA-9B2D-4AF54225C7CA}.Release|Win32.Build.0 = Release|Win32 25 | {CC158E1D-1364-43CA-9B2D-4AF54225C7CA}.Static Debug|Win32.ActiveCfg = Static Debug|Win32 26 | {CC158E1D-1364-43CA-9B2D-4AF54225C7CA}.Static Debug|Win32.Build.0 = Static Debug|Win32 27 | {11CD05F8-E5E1-476E-A75F-A112655D4E94}.Debug|Win32.ActiveCfg = Debug|Win32 28 | {11CD05F8-E5E1-476E-A75F-A112655D4E94}.Debug|Win32.Build.0 = Debug|Win32 29 | {11CD05F8-E5E1-476E-A75F-A112655D4E94}.DebugDLL|Win32.ActiveCfg = Debug|Win32 30 | {11CD05F8-E5E1-476E-A75F-A112655D4E94}.DebugDLL|Win32.Build.0 = Debug|Win32 31 | {11CD05F8-E5E1-476E-A75F-A112655D4E94}.Release|Win32.ActiveCfg = Release|Win32 32 | {11CD05F8-E5E1-476E-A75F-A112655D4E94}.Release|Win32.Build.0 = Release|Win32 33 | {11CD05F8-E5E1-476E-A75F-A112655D4E94}.Static Debug|Win32.ActiveCfg = Static Debug|Win32 34 | {11CD05F8-E5E1-476E-A75F-A112655D4E94}.Static Debug|Win32.Build.0 = Static Debug|Win32 35 | EndGlobalSection 36 | GlobalSection(SolutionProperties) = preSolution 37 | HideSolutionNode = FALSE 38 | EndGlobalSection 39 | EndGlobal 40 | -------------------------------------------------------------------------------- /bindings/lua/Makefile.am: -------------------------------------------------------------------------------- 1 | # These files are not mentioned in any other Makefile 2 | # compat-5.1.lua is only necessary for Lua 5.0 in distros where 3 | # it's not already installed. 4 | EXTRA_DIST = README test.lua.bottom compat-5.1r5/compat-5.1.lua 5 | 6 | LIB_VERSION_INFO=0:0:0 7 | 8 | LUA = @LUA@ 9 | LUA_INSTALL_CMOD = @LUA_INSTALL_CMOD@ 10 | LUA_INSTALL_LMOD = @LUA_INSTALL_LMOD@ 11 | LUA_DEFINES = @LUA_DEFINES@ 12 | LUA_CFLAGS = @LUA_CFLAGS@ 13 | LUA_LFLAGS = @LUA_LFLAGS@ 14 | 15 | CLEANFILES = rrd.o rrd.so test.lua test.rrd test.png 16 | 17 | lualibdir=$(LUA_INSTALL_CMOD) 18 | lualib_LTLIBRARIES = rrd.la 19 | if LUA_NEED_OUR_COMPAT51 20 | rrd_la_SOURCES = rrdlua.c compat-5.1r5/compat-5.1.c compat-5.1r5/compat-5.1.h 21 | compatdir = $(LUA_INSTALL_LMOD) 22 | compat_DATA = compat-5.1r5/compat-5.1.lua 23 | else 24 | rrd_la_SOURCES = rrdlua.c 25 | endif 26 | rrd_la_LIBADD = -lrrd -lm 27 | rrd_la_LDFLAGS = -module -version-info $(LIB_VERSION_INFO) $(LUA_LFLAGS) -L$(top_builddir)/src/.libs 28 | rrd_la_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir) $(LUA_CFLAGS) $(LUA_DEFINES) -DLIB_VERSION=\"$(LIB_VERSION)\" 29 | 30 | .PHONY: test.lua 31 | 32 | test.lua: test.lua.bottom 33 | @echo "-- Created by Makefile." > test.lua 34 | @echo "-- Test script adapted from the one in the Ruby binding." > test.lua 35 | @echo >> test.lua 36 | if LUA50 37 | @echo "--- compat-5.1.lua is only required for Lua 5.0 ----------" >> test.lua 38 | if LUA_NEED_OUR_COMPAT51 39 | if !LUA_SITE_LINSTALL 40 | @echo "original_LUA_PATH = LUA_PATH" >> test.lua 41 | @echo "-- try only compat-5.1.lua installed with RRDtool" >> test.lua 42 | @echo "LUA_PATH = '$(LUA_INSTALL_LMOD)/?.lua'" >> test.lua 43 | endif 44 | endif 45 | @echo "local r = pcall(require, 'compat-5.1')" >> test.lua 46 | @echo "if not r then" >> test.lua 47 | @echo " print('** compat-5.1.lua not found')" >> test.lua 48 | @echo " os.exit(1)" >> test.lua 49 | @echo "end" >> test.lua 50 | if LUA_NEED_OUR_COMPAT51 51 | if !LUA_SITE_LINSTALL 52 | @echo "LUA_PATH = original_LUA_PATH" >> test.lua 53 | @echo "original_LUA_PATH = nil" >> test.lua 54 | endif 55 | endif 56 | @echo "----------------------------------------------------------" >> test.lua 57 | @echo >> test.lua 58 | endif 59 | if !LUA_SITE_CINSTALL 60 | @echo "package.cpath = '$(LUA_INSTALL_CMOD)/?.so;' .. package.cpath" >> test.lua 61 | endif 62 | @cat test.lua.bottom >> test.lua 63 | 64 | test: test.lua 65 | $(LUA) test.lua 66 | 67 | -------------------------------------------------------------------------------- /doc/rrdpython.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | rrdpython - About the RRD Python bindings 4 | 5 | =head1 SYNOPSIS 6 | 7 | import rrdtool 8 | rrdtool.create('/tmp/test.rrd', 'DS:foo:GAUGE:20:0:U') 9 | 10 | =head1 DESCRIPTION 11 | 12 | The B functions are directly callable via the Python programming 13 | language. This wrapper implementation has been written from the scratch 14 | (without SWIG) 15 | 16 | The API's expects strings and/or list of strings as parameters to the functions. 17 | Please refer to the other B documentation for functions and valid arguments. 18 | 19 | =head1 EXAMPLES 20 | 21 | =head2 Example 1 22 | 23 | import sys 24 | sys.path.append('/path/to/rrdtool/lib/python2.6/site-packages/') 25 | import rrdtool, tempfile 26 | 27 | DAY = 86400 28 | YEAR = 365 * DAY 29 | fd,path = tempfile.mkstemp('.png') 30 | 31 | rrdtool.graph(path, 32 | '--imgformat', 'PNG', 33 | '--width', '540', 34 | '--height', '100', 35 | '--start', "-%i" % YEAR, 36 | '--end', "-1", 37 | '--vertical-label', 'Downloads/Day', 38 | '--title', 'Annual downloads', 39 | '--lower-limit', '0', 40 | 'DEF:downloads=downloads.rrd:downloads:AVERAGE', 41 | 'AREA:downloads#990033:Downloads') 42 | 43 | info = rrdtool.info('downloads.rrd') 44 | print info['last_update'] 45 | print info['ds[downloads].minimal_heartbeat'] 46 | 47 | =head2 Example 2 48 | 49 | import sys 50 | sys.path.append('/path/to/rrdtool/lib/python2.6/site-packages/') 51 | import rrdtool 52 | 53 | # in real life data_sources would be populated in loop or something similar 54 | data_sources=[ 'DS:speed1:COUNTER:600:U:U', 55 | 'DS:speed2:COUNTER:600:U:U', 56 | 'DS:speed3:COUNTER:600:U:U' ] 57 | 58 | rrdtool.create( 'speed.rrd', 59 | '--start', '920804400', 60 | data_sources, 61 | 'RRA:AVERAGE:0.5:1:24', 62 | 'RRA:AVERAGE:0.5:6:10' ) 63 | 64 | If you use the B make target you can drop to first sys.path.append 65 | line since the RRDtool module will be available everywhere. 66 | 67 | If RRDtool runs into trouble, it will throw an exception which you might want to catch. 68 | 69 | =head1 SEE ALSO 70 | 71 | rrdcreate, rrdupdate, rrdgraph, rrddump, rrdfetch, rrdtune, rrdlast, 72 | rrdxport, rrdinfo 73 | 74 | =head1 AUTHOR 75 | 76 | Hye-Shik Chang Eperky@i18n.orgE 77 | 78 | Alan Milligan Ealan.milligan@last-bastion.netE 79 | -------------------------------------------------------------------------------- /src/rrd_last.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * RRDtool 1.4.3 Copyright by Tobi Oetiker, 1997-2010 3 | ***************************************************************************** 4 | * rrd_last.c 5 | ***************************************************************************** 6 | * Initial version by Russ Wright, @Home Network, 9/28/98 7 | *****************************************************************************/ 8 | 9 | #include "rrd_tool.h" 10 | #include "rrd_client.h" 11 | 12 | time_t rrd_last( 13 | int argc, 14 | char **argv) 15 | { 16 | char *opt_daemon = NULL; 17 | int status; 18 | 19 | optind = 0; 20 | opterr = 0; /* initialize getopt */ 21 | 22 | while (42) { 23 | int opt; 24 | int option_index = 0; 25 | static struct option long_options[] = { 26 | {"daemon", required_argument, 0, 'd'}, 27 | {0, 0, 0, 0} 28 | }; 29 | 30 | opt = getopt_long(argc, argv, "d:", long_options, &option_index); 31 | 32 | if (opt == EOF) 33 | break; 34 | 35 | switch (opt) { 36 | case 'd': 37 | if (opt_daemon != NULL) 38 | free (opt_daemon); 39 | opt_daemon = strdup (optarg); 40 | if (opt_daemon == NULL) 41 | { 42 | rrd_set_error ("strdup failed."); 43 | return (-1); 44 | } 45 | break; 46 | 47 | default: 48 | rrd_set_error ("Usage: rrdtool %s [--daemon ] ", 49 | argv[0]); 50 | return (-1); 51 | break; 52 | } 53 | } /* while (42) */ 54 | 55 | if ((argc - optind) != 1) { 56 | rrd_set_error ("Usage: rrdtool %s [--daemon ] ", 57 | argv[0]); 58 | return (-1); 59 | } 60 | 61 | status = rrdc_flush_if_daemon(opt_daemon, argv[optind]); 62 | if (opt_daemon) free(opt_daemon); 63 | if (status) return (-1); 64 | 65 | return (rrd_last_r (argv[optind])); 66 | } 67 | 68 | time_t rrd_last_r( 69 | const char *filename) 70 | { 71 | time_t lastup = -1; 72 | rrd_file_t *rrd_file; 73 | 74 | rrd_t rrd; 75 | 76 | rrd_init(&rrd); 77 | rrd_file = rrd_open(filename, &rrd, RRD_READONLY); 78 | if (rrd_file != NULL) { 79 | lastup = rrd.live_head->last_up; 80 | rrd_close(rrd_file); 81 | } 82 | rrd_free(&rrd); 83 | return (lastup); 84 | } 85 | -------------------------------------------------------------------------------- /doc/rrdinfo.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | rrdinfo - extract header information from an RRD 4 | 5 | =head1 SYNOPSIS 6 | 7 | B B I 8 | S<[B<--daemon> I
]> 9 | 10 | =head1 DESCRIPTION 11 | 12 | The B function prints the header information from an RRD in 13 | a parsing friendly format. 14 | 15 | Check L if you are uncertain about the meaning of the 16 | individual keys. 17 | 18 | =over 8 19 | 20 | =item I 21 | 22 | The name of the B you want to examine. 23 | 24 | =item B<--daemon> I
25 | 26 | Address of the L daemon. If specified, a C command is sent 27 | to the server before reading the RRD files. This allows B to return 28 | fresh data even if the daemon is configured to cache values for a long time. 29 | For a list of accepted formats, see the B<-l> option in the L manual. 30 | 31 | rrdtool info --daemon unix:/var/run/rrdcached.sock /var/lib/rrd/foo.rrd 32 | 33 | =back 34 | 35 | =head1 EXAMPLE 36 | 37 | This is the output generated by running B on a simple RRD which 38 | contains two data sources and one RRA. Note that the number after the 39 | I keyword is in seconds since 1970. The string B 40 | stands for I<*UNKNOWN*> data. In the example it means that this RRD 41 | has neither minimum nor maximum values defined for either of its 42 | data sources. 43 | 44 | filename = "random.rrd" 45 | rrd_version = "0001" 46 | step = 300 47 | last_update = 955892996 48 | header_size = 2872 49 | ds[a].type = "GAUGE" 50 | ds[a].minimal_heartbeat = 600 51 | ds[a].min = NaN 52 | ds[a].max = NaN 53 | ds[a].last_ds = "UNKN" 54 | ds[a].value = 2.1824421548e+04 55 | ds[a].unknown_sec = 0 56 | ds[b].type = "GAUGE" 57 | ds[b].minimal_heartbeat = 600 58 | ds[b].min = NaN 59 | ds[b].max = NaN 60 | ds[b].last_ds = "UNKN" 61 | ds[b].value = 3.9620838224e+03 62 | ds[b].unknown_sec = 0 63 | rra[0].cf = "AVERAGE" 64 | rra[0].pdp_per_row = 1 65 | rra[0].cdp_prep[0].value = nan 66 | rra[0].cdp_prep[0].unknown_datapoints = 0 67 | rra[0].cdp_prep[1].value = nan 68 | rra[0].cdp_prep[1].unknown_datapoints = 0 69 | 70 | =head1 ENVIRONMENT VARIABLES 71 | 72 | The following environment variables may be used to change the behavior of 73 | Cinfo>: 74 | 75 | =over 4 76 | 77 | =item B 78 | 79 | If this environment variable is set it will have the same effect as specifying 80 | the C<--daemon> option on the command line. If both are present, the command 81 | line argument takes precedence. 82 | 83 | =back 84 | 85 | =head1 AUTHOR 86 | 87 | Tobias Oetiker Etobi@oetiker.chE 88 | 89 | -------------------------------------------------------------------------------- /bindings/lua/README: -------------------------------------------------------------------------------- 1 | RRDLua is a Lua module for RRD functions. 2 | 3 | - Configuration 4 | 5 | From the top dir of RRDtool package, run "./configure", or 6 | "./configure --enable-lua-site-install" if you prefer to install in 7 | Lua's search path. 8 | 9 | You should have lua 5.0, or superior, and respective lua-dev packages 10 | installed before executing configure. 11 | 12 | - Compilation and installation 13 | 14 | Run 'make' and 'sudo make install'. If you don't enable lua-site-install, 15 | the Lua modules will be installed together with RRDtool, under the subdir 16 | lib/lua/. 17 | 18 | - Testing 19 | 20 | Install RRDtool first, as above. Then, enter the bindings/lua dir, run 21 | 'make test' and use your preferred viewer to display the just created 22 | 'test.png'. If you can read "Enjoy Lua RRDtool module!" on the picture, 23 | everything went fine. 24 | 25 | - Using with Lua 5.1 26 | 27 | Start your programs with: 28 | 29 | ------..----------------------------------------------------------- 30 | package.cpath = ' send a message with the subject 'subscribe' 57 | to -request@lists.oetiker.ch 58 | 59 | Note, that postings to rrd-announce will always be cross-posted 60 | to rrd-users and rrd-developers as well. 61 | 62 | To Contribute: 63 | -------------- 64 | 65 | Contributed feature and bug patches are most welcome. But please 66 | send complete patches. A complete patch patches the CODE as well 67 | as the CHANGES, CONTRIBUTORS and the POD files. 68 | 69 | Use GNU diff --unified --recursive olddir newdir to build your patches. 70 | 71 | The latest Version: 72 | ------------------- 73 | Is available from http://oss.oetiker.ch/rrdtool/ 74 | 75 | 76 | Tobias Oetiker 77 | -------------------------------------------------------------------------------- /doc/rrddump.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | rrddump - dump the contents of an RRD to XML format 4 | 5 | =head1 SYNOPSIS 6 | 7 | B B I [I] 8 | S<[B<--header>|B<-h> {none,xsd,dtd}]> 9 | S<[B<--no-header>]> 10 | S<[B<--daemon> I
]> 11 | S I> 12 | 13 | =head1 DESCRIPTION 14 | 15 | The B function writes the contents of an B in human 16 | readable (?) XML format to a file or to stdout. This format can 17 | be read by rrdrestore. Together they allow you to transfer your 18 | files from one computer architecture to another as well to 19 | manipulate the contents of an B file in a somewhat more 20 | convenient manner. 21 | 22 | =over 8 23 | 24 | =item I 25 | 26 | The name of the B you want to dump. 27 | 28 | =item I 29 | 30 | The (optional) filename that you want to write the XML output to. 31 | If not specified, the XML will be printed to stdout. 32 | 33 | =item B<--header>|B<-h> {none,xsd,dtd} 34 | 35 | By default RRDtool will add a dtd header to the xml file. Here 36 | you can customize this to and xsd header or no header at all. 37 | 38 | 39 | =item B<--no-header> 40 | 41 | A shortcut for S<--header=none>. 42 | 43 | If you want to restore the dump with RRDtool 1.2 you should use the 44 | S<--no-header> option since 1.2 can not deal with xml headers. 45 | 46 | =item B<--daemon> I
47 | 48 | Address of the L daemon. If specified, a C command is sent 49 | to the server before reading the RRD files. This allows B to return 50 | fresh data even if the daemon is configured to cache values for a long time. 51 | For a list of accepted formats, see the B<-l> option in the L manual. 52 | 53 | rrdtool dump --daemon unix:/var/run/rrdcached.sock /var/lib/rrd/foo.rrd 54 | 55 | =back 56 | 57 | =head1 EXAMPLES 58 | 59 | To transfer an RRD between architectures, follow these steps: 60 | 61 | =over 4 62 | 63 | =item 1. 64 | 65 | On the same system where the RRD was created, use B B 66 | to export the data to XML format. 67 | 68 | =item 2. 69 | 70 | Transfer the XML dump to the target system. 71 | 72 | =item 3. 73 | 74 | Run B B to create a new RRD from the XML dump. See 75 | B for details. 76 | 77 | =back 78 | 79 | =head1 ENVIRONMENT VARIABLES 80 | 81 | The following environment variables may be used to change the behavior of 82 | Cdump>: 83 | 84 | =over 4 85 | 86 | =item B 87 | 88 | If this environment variable is set it will have the same effect as specifying 89 | the C<--daemon> option on the command line. If both are present, the command 90 | line argument takes precedence. 91 | 92 | =back 93 | 94 | =head1 AUTHOR 95 | 96 | Tobias Oetiker Etobi@oetiker.chE 97 | 98 | -------------------------------------------------------------------------------- /bindings/dotnet/dnrrdlib.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.21022 7 | 2.0 8 | {0688ED86-0E5F-4469-A7DB-D51024DE99E9} 9 | Library 10 | Properties 11 | dnrrdlib 12 | dnrrdlib 13 | v3.5 14 | 512 15 | favicon.ico 16 | 17 | 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 3.5 38 | 39 | 40 | 3.5 41 | 42 | 43 | 3.5 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 63 | -------------------------------------------------------------------------------- /bindings/lua/test.lua.bottom: -------------------------------------------------------------------------------- 1 | 2 | local rrd = require 'rrd' 3 | 4 | local name = 'test.rrd' 5 | local start = 300 * math.floor(os.time() / 300) 6 | 7 | io.write('\n-- Creating ', name, '\n') 8 | rrd.create( 9 | name, 10 | '--start', start-1, 11 | '--step', '300', 12 | 'DS:a:GAUGE:600:U:U', 13 | 'DS:b:GAUGE:600:U:U', 14 | 'RRA:AVERAGE:0.5:1:300') 15 | 16 | local num_points = 0 17 | for t=start, start+300*300, 300 do 18 | local s = string.format('%d:%d:%f', t, 19 | math.random(100), math.sin(t/800)*50+50) 20 | rrd.update(name, s) 21 | num_points = num_points + 1 22 | end 23 | 24 | io.write('rrd file created with ', num_points, ' points, from ', start, 25 | ' to ', start+300*300, '\n') 26 | 27 | io.write('\n-- Testing rrd.info\n') 28 | local info = rrd.info(name) 29 | for k,v in pairs(info) do 30 | io.write(k, '=', v, '\n') 31 | end 32 | io.write('\n') 33 | 34 | io.write('-- Testing rrd.fetch\n') 35 | io.write('fetching data from ', name, ' - interval: ', start, ' to ', 36 | start+300*300, '\n') 37 | local fstart, fstep, fnames, fdata = 38 | rrd.fetch(name, '--start', start, '--end', start+300*300+10, 'AVERAGE') 39 | io.write('got ', table.getn(fdata[1]), ' data sources with ', table.getn(fdata), 40 | ' data points each.\n') 41 | 42 | io.write('\n-- Printing fetched data\n') 43 | io.write(' ') 44 | for i, n in ipairs(fnames) do 45 | io.write(n, ' ') 46 | end 47 | io.write('\n') 48 | for i, v in ipairs(fdata) do 49 | local time = fstart + (i-1)*fstep 50 | io.write(string.format('%s (%d): ', os.date('%c', time), time)) 51 | for _, w in ipairs(v) do 52 | io.write(string.format('%e ', w)) 53 | end 54 | io.write('\n') 55 | end 56 | io.write('\n') 57 | 58 | io.write('\n-- Testing rrd.graphv - creates test.png and returns values\n') 59 | local t = rrd.graphv( 60 | 'test.png', 61 | '--title', 'Enjoy Lua RRDtool module!', 62 | '--start', start+3600, 63 | '--end', 'start + 1000 min', 64 | '--interlace', 65 | '--imgformat', 'PNG', 66 | '--width=450', 67 | 'DEF:a=' .. name .. ':a:AVERAGE', 68 | 'DEF:b=' .. name .. ':b:AVERAGE', 69 | 'CDEF:line=TIME,2400,%,300,LT,a,UNKN,IF', 70 | 'AREA:b#00b6e4:beta', 71 | 'AREA:line#0022e9:alpha', 72 | 'LINE3:line#ff0000', 73 | 'VDEF:va=a,AVERAGE', 74 | 'VDEF:vb=b,AVERAGE', 75 | 'PRINT:va:%5.2lf', 76 | 'PRINT:vb:%5.2lf') 77 | 78 | io.write('\n-- Returned values:\n') 79 | io.write('print[0]: ', t['print[0]'], '\n') 80 | io.write('print[1]: ', t['print[1]'], '\n') 81 | for k, v in pairs(t) do 82 | if not string.find(k, '^print%[%d+%]') then 83 | io.write(k, ': ', v, '\n') 84 | end 85 | end 86 | io.write('\n') 87 | 88 | io.write('-- The graph "test.png" was created.\n') 89 | io.write('-- Use your preferred viewer to display it.\n\n') 90 | 91 | -------------------------------------------------------------------------------- /bindings/Makefile.am: -------------------------------------------------------------------------------- 1 | .PHONY: python ruby 2 | 3 | if BUILD_TCL 4 | SUB_tcl = tcl 5 | endif 6 | if BUILD_LUA 7 | SUB_lua = lua 8 | endif 9 | 10 | SUBDIRS = $(SUB_tcl) $(SUB_lua) 11 | 12 | # the following files are not mentioned in any other Makefile 13 | EXTRA_DIST = perl-piped/MANIFEST perl-piped/README perl-piped/Makefile.PL perl-piped/RRDp.pm perl-piped/t/base.t \ 14 | perl-shared/ntmake-build perl-shared/MANIFEST perl-shared/README perl-shared/Makefile.PL perl-shared/RRDs.pm perl-shared/RRDs.xs perl-shared/t/base.t \ 15 | ruby/CHANGES ruby/README ruby/extconf.rb ruby/main.c ruby/test.rb \ 16 | python/ACKNOWLEDGEMENT python/AUTHORS python/COPYING python/README python/rrdtoolmodule.c python/setup.py 17 | 18 | 19 | # add the following to the all target 20 | all-local: @COMP_PERL@ @COMP_RUBY@ @COMP_PYTHON@ 21 | 22 | install-data-local: 23 | $(AM_V_GEN)test -f perl-piped/Makefile && cd perl-piped && $(MAKE) install || true 24 | $(AM_V_GEN)test -f perl-shared/Makefile && cd perl-shared && $(MAKE) install || true 25 | $(AM_V_GEN)test -f ruby/Makefile && cd ruby && $(MAKE) EPREFIX=$(DESTDIR)$(exec_prefix) $(RUBY_MAKE_OPTIONS) install || true 26 | $(AM_V_GEN)test -d python/build && cd python && env BUILDLIBDIR=../../src/.libs $(PYTHON) setup.py install --skip-build --prefix=$(DESTDIR)$(prefix) --exec-prefix=$(DESTDIR)$(exec_prefix) || true 27 | 28 | # rules for building the ruby module 29 | # RUBYARCHDIR= is to work around in a makefile quirk not sure 30 | # it is is the right thing todo, but it makes rrdtool build on freebsd as well 31 | ruby: Makefile 32 | cd ruby && $(RUBY) extconf.rb && $(MAKE) EPREFIX=$(exec_prefix) $(RUBY_MAKE_OPTIONS) RUBYARCHDIR= 33 | 34 | # rules for building the pyton module 35 | python: Makefile 36 | cd python && env BUILDLIBDIR=../../src/.libs $(PYTHON) setup.py build_ext --rpath=$(libdir) && env LIBDIR=../../src/.libs $(PYTHON) setup.py build 37 | 38 | # rules for building the perl module 39 | perl_piped: perl-piped/Makefile 40 | cd perl-piped && $(MAKE) 41 | 42 | perl-piped/Makefile: perl-piped/Makefile.PL 43 | cd perl-piped && $(PERL) Makefile.PL $(PERL_MAKE_OPTIONS) 44 | 45 | perl_shared: perl-shared/Makefile 46 | cd perl-shared && $(MAKE) 47 | 48 | perl-shared/Makefile: perl-shared/Makefile.PL Makefile 49 | cd perl-shared && $(PERL) Makefile.PL $(PERLFLAGS) $(PERL_MAKE_OPTIONS) RPATH=$(libdir) 50 | # LIBS="$(LDFLAGS) $(LIBS)" $(PERLFLAGS) $(PERL_MAKE_OPTIONS) 51 | 52 | clean-local: 53 | test -f perl-piped/Makefile && cd perl-piped && $(MAKE) clean || true 54 | test -f perl-piped/Makefile && rm perl-piped/Makefile || true 55 | test -f perl-shared/Makefile && cd perl-shared && $(MAKE) clean || true 56 | test -f perl-shared/Makefile && rm -f perl-shared/Makefile || true 57 | test -f ruby/Makefile && cd ruby && $(MAKE) clean && rm Makefile || true 58 | test -d python/build && cd python && rm -rf build || true 59 | ##END## 60 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | SUFFIXES = .pod .pl .1 .3 .man .html .txt .pm .pdf .inc 4 | 5 | AUTOMAKE_OPTIONS = foreign 6 | 7 | #ACLOCAL_M4 = $(top_srcdir)/config/aclocal.m4 8 | 9 | CLEANFILES = *.1 *.3 *.html *.txt *-dircache RRD?.pod *.pdf *~ core *itemcache *.rej *.orig *.tmp 10 | 11 | POD = bin_dec_hex.pod rrddump.pod rrdgraph_examples.pod rrdrestore.pod rrdupdate.pod \ 12 | cdeftutorial.pod rrdfetch.pod rrdgraph_graph.pod rrdthreads.pod rrdxport.pod \ 13 | rpntutorial.pod rrdfirst.pod rrdgraph_rpn.pod rrdtool.pod rrdcached.pod \ 14 | rrd-beginners.pod rrdinfo.pod rrdtune.pod rrdbuild.pod rrdflushcached.pod \ 15 | rrdcgi.pod rrdgraph.pod rrdlast.pod rrdlastupdate.pod \ 16 | rrdcreate.pod rrdgraph_data.pod rrdresize.pod rrdtutorial.pod 17 | 18 | if BUILD_LIBDBI 19 | POD += rrdgraph_libdbi.pod 20 | endif 21 | 22 | if BUILD_LUA 23 | POD += rrdlua.pod 24 | endif 25 | 26 | POD3 = librrd.pod 27 | 28 | PMP = RRDs.pod RRDp.pod 29 | 30 | MAN = $(POD:.pod=.1) 31 | MAN3 = $(POD3:.pod=.3) 32 | TXT = $(MAN:.1=.txt) $(MAN3:.3=.txt) 33 | HTML = $(POD:.pod=.html) $(POD3:.pod=.html) $(PMP:.pod=.html) 34 | PDF = $(MAN:.1=.pdf) $(MAN3:.3=.pdf) 35 | 36 | # what should go into the distribution 37 | EXTRA_DIST= $(POD) $(POD3) $(HTML) $(MAN) $(MAN3) $(TXT) rrdtool-dump.dtd rrdtool-xport.dtd rrdgraph_libdbi.pod rrdlua.pod 38 | 39 | idocdir = $(RRDDOCDIR)/txt 40 | idoc_DATA = $(POD) $(TXT) 41 | ihtmldir = $(RRDDOCDIR)/html 42 | ihtml_DATA = $(HTML) 43 | imandir = $(mandir)/man1 44 | iman_DATA = $(MAN) 45 | iman3dir = $(mandir)/man3 46 | iman3_DATA = $(MAN3) 47 | 48 | all-local: link man txt html-local 49 | 50 | .src.pod: 51 | perl -n -e 'if (/^=include\s+(\S+)/){open F,"$$1.inc" || die $$?;print ; close F} else {print}' $< > $@ 52 | 53 | .pod.1 .pm.1 .pl.1: 54 | $(AM_V_GEN)@POD2MAN@ --release=$(VERSION) --center=rrdtool $< > $@ 55 | 56 | .pod.3: 57 | $(AM_V_GEN)@POD2MAN@ --release=$(VERSION) --center=rrdtool --section=3 $< > $@ 58 | 59 | .1.txt .3.txt: 60 | $(AM_V_GEN)GROFF_NO_SGR=1 @NROFF@ -man -Tlp $< > $@ 61 | 62 | .1.pdf .3.pdf: 63 | $(AM_V_GEN)@TROFF@ -man $< | ps2pdf - $@ 64 | 65 | .pm.html .pod.html .pl.html: 66 | $(AM_V_GEN)@POD2HTML@ --infile=$< --outfile=$@ --noindex --htmlroot=. --podpath=. --title=$* 67 | 68 | RRDs.pod: 69 | $(AM_V_GEN)$(LN_S) $(top_srcdir)/bindings/perl-shared/RRDs.pm RRDs.pod 70 | 71 | RRDp.pod: 72 | $(AM_V_GEN)$(LN_S) $(top_srcdir)/bindings/perl-piped/RRDp.pm RRDp.pod 73 | 74 | link: RRDp.pod RRDs.pod 75 | 76 | man: $(MAN) $(MAN3) 77 | 78 | html-local: $(HTML) 79 | 80 | txt: $(TXT) 81 | 82 | pdf-local: $(PDF) 83 | 84 | pod: $(POD) $(POD3) 85 | 86 | install-data-hook: 87 | $(AM_V_GEN)cd $(DESTDIR)$(ihtmldir) && rm -f index.html && $(LN_S) rrdtool.html index.html 88 | -------------------------------------------------------------------------------- /bindings/dotnet/dnrrd_binding_test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.21022 7 | 2.0 8 | {2BB82CAE-A379-46D9-B2B5-13DC4DB3209C} 9 | Exe 10 | Properties 11 | dnrrd_binding_test 12 | dnrrd_binding_test 13 | v3.5 14 | 512 15 | favicon.ico 16 | 17 | 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 3.5 38 | 39 | 40 | 3.5 41 | 42 | 43 | 3.5 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | {0688ED86-0E5F-4469-A7DB-D51024DE99E9} 55 | dnrrdlib 56 | 57 | 58 | 59 | 60 | 61 | 62 | 69 | -------------------------------------------------------------------------------- /src/rrd_first.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * RRDtool 1.4.3 Copyright by Tobi Oetiker, 1997-2010 3 | ***************************************************************************** 4 | * rrd_first Return 5 | ***************************************************************************** 6 | * Initial version by Burton Strauss, ntopSupport.com - 3/2005 7 | *****************************************************************************/ 8 | 9 | #include 10 | #include "rrd_tool.h" 11 | 12 | 13 | time_t rrd_first( 14 | int argc, 15 | char **argv) 16 | { 17 | int target_rraindex = 0; 18 | char *endptr; 19 | struct option long_options[] = { 20 | {"rraindex", required_argument, 0, 129}, 21 | {0, 0, 0, 0} 22 | }; 23 | 24 | optind = 0; 25 | opterr = 0; /* initialize getopt */ 26 | 27 | while (1) { 28 | int option_index = 0; 29 | int opt; 30 | 31 | opt = getopt_long(argc, argv, "", long_options, &option_index); 32 | 33 | if (opt == EOF) 34 | break; 35 | 36 | switch (opt) { 37 | case 129: 38 | target_rraindex = strtol(optarg, &endptr, 0); 39 | if (target_rraindex < 0) { 40 | rrd_set_error("invalid rraindex number"); 41 | return (-1); 42 | } 43 | break; 44 | default: 45 | rrd_set_error("usage rrdtool %s [--rraindex number] file.rrd", 46 | argv[0]); 47 | return (-1); 48 | } 49 | } 50 | 51 | if (optind >= argc) { 52 | rrd_set_error("not enough arguments"); 53 | return -1; 54 | } 55 | 56 | return (rrd_first_r(argv[optind], target_rraindex)); 57 | } 58 | 59 | 60 | time_t rrd_first_r( 61 | const char *filename, 62 | const int rraindex) 63 | { 64 | off_t rra_start, timer; 65 | time_t then = -1; 66 | rrd_t rrd; 67 | rrd_file_t *rrd_file; 68 | 69 | rrd_init(&rrd); 70 | rrd_file = rrd_open(filename, &rrd, RRD_READONLY); 71 | if (rrd_file == NULL) { 72 | goto err_free; 73 | } 74 | 75 | if ((rraindex < 0) || (rraindex >= (int) rrd.stat_head->rra_cnt)) { 76 | rrd_set_error("invalid rraindex number"); 77 | goto err_close; 78 | } 79 | 80 | rra_start = rrd_file->header_len; 81 | rrd_seek(rrd_file, 82 | (rra_start + 83 | (rrd.rra_ptr[rraindex].cur_row + 1) * 84 | rrd.stat_head->ds_cnt * sizeof(rrd_value_t)), SEEK_SET); 85 | timer = -(long)(rrd.rra_def[rraindex].row_cnt - 1); 86 | if (rrd.rra_ptr[rraindex].cur_row + 1 > rrd.rra_def[rraindex].row_cnt) { 87 | rrd_seek(rrd_file, rra_start, SEEK_SET); 88 | } 89 | then = (rrd.live_head->last_up - 90 | rrd.live_head->last_up % 91 | (rrd.rra_def[rraindex].pdp_cnt * rrd.stat_head->pdp_step)) + 92 | (timer * rrd.rra_def[rraindex].pdp_cnt * rrd.stat_head->pdp_step); 93 | err_close: 94 | rrd_close(rrd_file); 95 | err_free: 96 | rrd_free(&rrd); 97 | return (then); 98 | } 99 | -------------------------------------------------------------------------------- /src/rrd_rpncalc.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * RRDtool 1.4.3 Copyright by Tobi Oetiker, 1997-2010 3 | **************************************************************************** 4 | * rrd_rpncalc.h RPN calculator functions 5 | ****************************************************************************/ 6 | #ifndef _RRD_RPNCALC_H 7 | #define _RRD_RPNCALC_H 8 | 9 | /* WARNING: if new operators are added, they MUST be added at the very end of the list. 10 | * This is because COMPUTE (CDEF) DS store OP nodes by number (name is not 11 | * an option due to limited par array size). OP nodes must have the same 12 | * numeric values, otherwise the stored numbers will mean something different. */ 13 | enum op_en { OP_NUMBER = 0, OP_VARIABLE, OP_INF, OP_PREV, OP_NEGINF, 14 | OP_UNKN, OP_NOW, OP_TIME, OP_ADD, OP_MOD, OP_SUB, OP_MUL, 15 | OP_DIV, OP_SIN, OP_DUP, OP_EXC, OP_POP, 16 | OP_COS, OP_LOG, OP_EXP, OP_LT, OP_LE, OP_GT, OP_GE, OP_EQ, OP_IF, 17 | OP_MIN, OP_MAX, OP_LIMIT, OP_FLOOR, OP_CEIL, 18 | OP_UN, OP_END, OP_LTIME, OP_NE, OP_ISINF, OP_PREV_OTHER, OP_COUNT, 19 | OP_ATAN, OP_SQRT, OP_SORT, OP_REV, OP_TREND, OP_TRENDNAN, 20 | OP_ATAN2, OP_RAD2DEG, OP_DEG2RAD, 21 | OP_PREDICT,OP_PREDICTSIGMA, 22 | OP_AVG, OP_ABS, OP_ADDNAN 23 | }; 24 | 25 | typedef struct rpnp_t { 26 | enum op_en op; 27 | double val; /* value for a OP_NUMBER */ 28 | long ptr; /* pointer into the gdes array for OP_VAR */ 29 | double *data; /* pointer to the current value from OP_VAR DAS */ 30 | long ds_cnt; /* data source count for data pointer */ 31 | long step; /* time step for OP_VAR das */ 32 | } rpnp_t; 33 | 34 | /* a compact representation of rpnp_t for computed data sources */ 35 | typedef struct rpn_cdefds_t { 36 | char op; /* rpn operator type */ 37 | short val; /* used by OP_NUMBER and OP_VARIABLE */ 38 | } rpn_cdefds_t; 39 | 40 | #define MAX_VNAME_LEN 255 41 | #define DEF_NAM_FMT "%255[-_A-Za-z0-9]" 42 | 43 | /* limit imposed by sizeof(rpn_cdefs_t) and rrd.ds_def.par */ 44 | #define DS_CDEF_MAX_RPN_NODES 26 45 | 46 | typedef struct rpnstack_t { 47 | double *s; 48 | long dc_stacksize; 49 | long dc_stackblock; 50 | } rpnstack_t; 51 | 52 | void rpnstack_init( 53 | rpnstack_t *rpnstack); 54 | void rpnstack_free( 55 | rpnstack_t *rpnstack); 56 | 57 | void parseCDEF_DS( 58 | const char *def, 59 | rrd_t *rrd, 60 | int ds_idx); 61 | long lookup_DS( 62 | void *rrd_vptr, 63 | char *ds_name); 64 | 65 | short rpn_compact( 66 | rpnp_t *rpnp, 67 | rpn_cdefds_t **rpnc, 68 | short *count); 69 | rpnp_t *rpn_expand( 70 | rpn_cdefds_t *rpnc); 71 | void rpn_compact2str( 72 | rpn_cdefds_t *rpnc, 73 | ds_def_t *ds_def, 74 | char **str); 75 | rpnp_t *rpn_parse( 76 | void *key_hash, 77 | const char *const expr, 78 | long (*lookup) (void *, 79 | char *)); 80 | short rpn_calc( 81 | rpnp_t *rpnp, 82 | rpnstack_t *rpnstack, 83 | long data_idx, 84 | rrd_value_t *output, 85 | int output_idx); 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /examples/4charts.pl.in: -------------------------------------------------------------------------------- 1 | #! @PERL@ 2 | 3 | #makes things work when run without install 4 | use lib qw( @prefix@/lib/perl ); 5 | 6 | use RRDs; 7 | 8 | my $start=time; 9 | my $rrd="randome.rrd"; 10 | my $name = $0; 11 | $name =~ s/.*\///g; 12 | $name =~ s/\.pl.*//g; 13 | 14 | RRDs::create ($rrd, "--start",$start-1, "--step",300, 15 | "DS:a:GAUGE:600:U:U", 16 | "DS:b:GAUGE:600:U:U", 17 | "RRA:AVERAGE:0.5:1:300", 18 | "RRA:MIN:0.5:12:300", 19 | "RRA:MAX:0.5:12:300", 20 | ); 21 | 22 | my $ERROR = RRDs::error; 23 | die "$0: unable to create `$rrd': $ERROR\n" if $ERROR; 24 | 25 | # dropt some data into the rrd 26 | my $t; 27 | for ($t=$start; $t<$start+300*300; $t+=300){ 28 | RRDs::update $rrd, "$t:".(sin($t/3000)*50+50).":".(sin($t/2500)*50+50); 29 | if ($ERROR = RRDs::error) { 30 | die "$0: unable to update `$rrd': $ERROR\n"; 31 | } 32 | } 33 | 34 | my $c1="f57912a0"; 35 | my $c2="2a79e9a0"; 36 | my $w=300; 37 | my $h=140; 38 | 39 | RRDs::graph "$name-L.png", 40 | "--title", "2 LINES", 41 | "--start", "now", 42 | "--end", "start+15h", 43 | "--lower-limit=0", 44 | "--interlace", 45 | "--imgformat","PNG", 46 | "--width=$w", 47 | "--height=$h", 48 | "DEF:a=$rrd:a:AVERAGE", 49 | "DEF:b=$rrd:b:AVERAGE", 50 | "LINE1:a#$c1:Value A", 51 | "LINE3:b#$c2:Value B", 52 | ; 53 | 54 | RRDs::graph "$name-A.png", 55 | "--title", "LINE and AREA", 56 | "--start", "now", 57 | "--end", "start+15h", 58 | "--lower-limit=0", 59 | "--interlace", 60 | "--imgformat","PNG", 61 | "--width=$w", 62 | "--height=$h", 63 | "DEF:a=$rrd:a:AVERAGE", 64 | "DEF:b=$rrd:b:AVERAGE", 65 | "AREA:a#$c1:Value A", 66 | "LINE2:b#$c2:Value B", 67 | ; 68 | 69 | RRDs::graph "$name-S.png", 70 | "--title", "STACKED AREAS", 71 | "--start", "now", 72 | "--end", "start+15h", 73 | "--lower-limit=0", 74 | "--interlace", 75 | "--imgformat","PNG", 76 | "--width=$w", 77 | "--height=$h", 78 | "DEF:a=$rrd:a:AVERAGE", 79 | "DEF:b=$rrd:b:AVERAGE", 80 | "AREA:a#$c1:Value A", 81 | "STACK:b#$c2:Value B", 82 | ; 83 | 84 | 85 | RRDs::graph "$name-M.png", 86 | "--title", "RPN Magic", 87 | "--start", "now", 88 | "--end", "start+15h", 89 | "--lower-limit=0", 90 | "--interlace", 91 | "--imgformat","PNG", 92 | "--width=$w", 93 | "--height=$h", 94 | "DEF:a=$rrd:a:AVERAGE", 95 | "DEF:b=$rrd:b:AVERAGE", 96 | "CDEF:alpha=TIME,3600,%,1800,LT,a,UNKN,IF", 97 | "CDEF:beta=TIME,3600,%,1800,GE,b,UNKN,IF", 98 | "AREA:alpha#$c1:Value A", 99 | "LINE1:a#$c1", 100 | "AREA:beta#$c2:Value B", 101 | "LINE1:b#$c2", 102 | ; 103 | 104 | RRDs::graph "$name-sample.png", 105 | "--title", "Sample", 106 | "--start", "now", 107 | "--end", "start+15h", 108 | "--lower-limit=0", 109 | "--interlace", 110 | "--imgformat","PNG", 111 | "--width=600", 112 | "--height=50", 113 | "DEF:a=$rrd:a:AVERAGE", 114 | "DEF:b=$rrd:a:MAX", 115 | "AREA:a#00ff00:Incoming", 116 | "LINE1:b#ff0000:Max Incoming", 117 | ; 118 | 119 | if ($ERROR = RRDs::error) { 120 | die "ERROR: $ERROR\n"; 121 | }; 122 | 123 | print "This script has created $name.png in the current directory\n"; 124 | print "This demonstrates the use of the TIME and % RPN operators\n"; 125 | -------------------------------------------------------------------------------- /src/rrd_tool.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * RRDtool 1.4.3 Copyright by Tobi Oetiker, 1997-2010 3 | ***************************************************************************** 4 | * rrd_tool.h Common Header File 5 | *****************************************************************************/ 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #ifndef _RRD_TOOL_H 11 | #define _RRD_TOOL_H 12 | 13 | #ifdef HAVE_CONFIG_H 14 | #include "../rrd_config.h" 15 | #elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) 16 | #include "../win32/config.h" 17 | #endif 18 | 19 | #include "rrd.h" 20 | 21 | #if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) 22 | 23 | /* Win32 only includes */ 24 | 25 | #include /* for _isnan */ 26 | #include /* for chdir */ 27 | 28 | struct tm *localtime_r( 29 | const time_t *timep, 30 | struct tm *result); 31 | char *ctime_r( 32 | const time_t *timep, 33 | char *result); 34 | struct tm *gmtime_r( 35 | const time_t *timep, 36 | struct tm *result); 37 | char *strtok_r( 38 | char *str, 39 | const char *sep, 40 | char **last); 41 | 42 | #else 43 | 44 | /* unix-only includes */ 45 | #if !defined isnan && !defined HAVE_ISNAN 46 | int isnan( 47 | double value); 48 | #endif 49 | 50 | #endif 51 | 52 | /* local include files -- need to be after the system ones */ 53 | #ifdef HAVE_GETOPT_LONG 54 | #define _GNU_SOURCE 55 | #include 56 | #else 57 | #include "rrd_getopt.h" 58 | #endif 59 | 60 | #include "rrd_format.h" 61 | 62 | #ifndef max 63 | #define max(a,b) ((a) > (b) ? (a) : (b)) 64 | #endif 65 | 66 | #ifndef min 67 | #define min(a,b) ((a) < (b) ? (a) : (b)) 68 | #endif 69 | 70 | #define DIM(x) (sizeof(x)/sizeof(x[0])) 71 | 72 | char *sprintf_alloc( 73 | char *, 74 | ...); 75 | 76 | /* HELPER FUNCTIONS */ 77 | 78 | int PngSize( 79 | FILE *, 80 | long *, 81 | long *); 82 | 83 | int rrd_create_fn( 84 | const char *file_name, 85 | rrd_t *rrd); 86 | int rrd_fetch_fn (const char *filename, 87 | enum cf_en cf_idx, 88 | time_t *start, 89 | time_t *end, 90 | unsigned long *step, 91 | unsigned long *ds_cnt, 92 | char ***ds_namv, 93 | rrd_value_t **data); 94 | 95 | 96 | #ifdef HAVE_LIBDBI 97 | int rrd_fetch_fn_libdbi(const char *filename, enum cf_en cf_idx, 98 | time_t *start,time_t *end, 99 | unsigned long *step, 100 | unsigned long *ds_cnt, 101 | char ***ds_namv, 102 | rrd_value_t **data); 103 | #endif 104 | 105 | #define RRD_READONLY (1<<0) 106 | #define RRD_READWRITE (1<<1) 107 | #define RRD_CREAT (1<<2) 108 | #define RRD_READAHEAD (1<<3) 109 | #define RRD_COPY (1<<4) 110 | #define RRD_EXCL (1<<5) 111 | 112 | enum cf_en cf_conv( 113 | const char *string); 114 | enum dst_en dst_conv( 115 | char *string); 116 | long ds_match( 117 | rrd_t *rrd, 118 | char *ds_nam); 119 | off_t rrd_get_header_size( 120 | rrd_t *rrd); 121 | double rrd_diff( 122 | char *a, 123 | char *b); 124 | 125 | const char *cf_to_string (enum cf_en cf); 126 | 127 | #endif /* _RRD_TOOL_H */ 128 | 129 | #ifdef __cplusplus 130 | } 131 | #endif 132 | -------------------------------------------------------------------------------- /src/fnv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fnv - Fowler/Noll/Vo- hash code 3 | * 4 | * @(#) $Revision$ 5 | * @(#) $Id$ 6 | * @(#) $Source$ 7 | * 8 | *** 9 | * 10 | * Fowler/Noll/Vo- hash 11 | * 12 | * The basis of this hash algorithm was taken from an idea sent 13 | * as reviewer comments to the IEEE POSIX P1003.2 committee by: 14 | * 15 | * Phong Vo (http://www.research.att.com/info/kpv/) 16 | * Glenn Fowler (http://www.research.att.com/~gsf/) 17 | * 18 | * In a subsequent ballot round: 19 | * 20 | * Landon Curt Noll (http://reality.sgi.com/chongo/) 21 | * 22 | * improved on their algorithm. Some people tried this hash 23 | * and found that it worked rather well. In an EMail message 24 | * to Landon, they named it the ``Fowler/Noll/Vo'' or FNV hash. 25 | * 26 | * FNV hashes are architected to be fast while maintaining a low 27 | * collision rate. The FNV speed allows one to quickly hash lots 28 | * of data while maintaining a reasonable collision rate. See: 29 | * 30 | * http://reality.sgi.com/chongo/tech/comp/fnv/ 31 | * 32 | * for more details as well as other forms of the FNV hash. 33 | * 34 | *** 35 | * 36 | * NOTE: The FNV-0 historic hash is not recommended. One should use 37 | * the FNV-1 hash instead. 38 | * 39 | * To use the 32 bit FNV-0 historic hash, pass FNV0_32_INIT as the 40 | * Fnv32_t hashval argument to fnv_32_buf() or fnv_32_str(). 41 | * 42 | * To use the 64 bit FNV-0 historic hash, pass FNV0_64_INIT as the 43 | * Fnv64_t hashval argument to fnv_64_buf() or fnv_64_str(). 44 | * 45 | * To use the recommended 32 bit FNV-1 hash, pass FNV1_32_INIT as the 46 | * Fnv32_t hashval argument to fnv_32_buf() or fnv_32_str(). 47 | * 48 | * To use the recommended 64 bit FNV-1 hash, pass FNV1_64_INIT as the 49 | * Fnv64_t hashval argument to fnv_64_buf() or fnv_64_str(). 50 | * 51 | *** 52 | * 53 | * Please do not copyright this code. This code is in the public domain. 54 | * 55 | * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 56 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO 57 | * EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR 58 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 59 | * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 60 | * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 61 | * PERFORMANCE OF THIS SOFTWARE. 62 | * 63 | * By: 64 | * chongo /\oo/\ 65 | * http://reality.sgi.com/chongo/ 66 | * EMail: chongo_fnv at prime dot engr dot sgi dot com 67 | * 68 | * Share and Enjoy! :-) 69 | */ 70 | 71 | #if !defined(__FNV_H__) 72 | #define __FNV_H__ 73 | 74 | 75 | /* 76 | * 32 bit FNV-0 hash type 77 | */ 78 | typedef unsigned long Fnv32_t; 79 | 80 | 81 | /* 82 | * 32 bit FNV-0 zero initial basis 83 | * 84 | * This historic hash is not recommended. One should use 85 | * the FNV-1 hash and inital basis instead. 86 | */ 87 | #define FNV0_32_INIT ((Fnv32_t)0) 88 | 89 | 90 | /* 91 | * 32 bit FNV-1 non-zero initial basis 92 | * 93 | * The FNV-1 initial basis is the FNV-0 hash of the following 32 octets: 94 | * 95 | * chongo /\../\ 96 | * 97 | * Note that the \'s above are not back-slashing escape characters. 98 | * They are literal ASCII backslash 0x5c characters. 99 | */ 100 | #define FNV1_32_INIT ((Fnv32_t)0x811c9dc5) 101 | 102 | Fnv32_t fnv_32_buf( 103 | const void *, 104 | size_t, 105 | Fnv32_t); 106 | 107 | Fnv32_t fnv_32_str( 108 | const char *, 109 | Fnv32_t); 110 | 111 | unsigned long FnvHash( 112 | const char *); 113 | 114 | #endif /* __FNV_H__ */ 115 | -------------------------------------------------------------------------------- /src/rrd_client.h: -------------------------------------------------------------------------------- 1 | /** 2 | * RRDTool - src/rrd_client.h 3 | * Copyright (C) 2008-2010 Florian octo Forster 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to 7 | * deal in the Software without restriction, including without limitation the 8 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9 | * sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 | * IN THE SOFTWARE. 22 | * 23 | * Authors: 24 | * Florian octo Forster 25 | **/ 26 | 27 | #ifndef __RRD_CLIENT_H 28 | #define __RRD_CLIENT_H 1 29 | 30 | #ifndef WIN32 31 | # ifdef HAVE_STDINT_H 32 | # include 33 | # else 34 | # ifdef HAVE_INTTYPES_H 35 | # include 36 | # else 37 | # error "you should have stdint.h or inttypes.h to compile this" 38 | # endif 39 | # endif 40 | #else 41 | # include 42 | typedef signed char int8_t; 43 | typedef unsigned char uint8_t; 44 | typedef signed int int16_t; 45 | typedef unsigned int uint16_t; 46 | typedef signed long int int32_t; 47 | typedef unsigned long int uint32_t; 48 | typedef signed long long int int64_t; 49 | typedef unsigned long long int uint64_t; 50 | #endif 51 | 52 | 53 | #ifndef RRDCACHED_DEFAULT_ADDRESS 54 | # define RRDCACHED_DEFAULT_ADDRESS "unix:/tmp/rrdcached.sock" 55 | #endif 56 | 57 | #define RRDCACHED_DEFAULT_PORT "42217" 58 | #define ENV_RRDCACHED_ADDRESS "RRDCACHED_ADDRESS" 59 | 60 | 61 | // Windows version has no daemon/client support 62 | 63 | #ifndef WIN32 64 | int rrdc_connect (const char *addr); 65 | int rrdc_is_connected(const char *daemon_addr); 66 | int rrdc_disconnect (void); 67 | 68 | int rrdc_update (const char *filename, int values_num, 69 | const char * const *values); 70 | 71 | int rrdc_flush (const char *filename); 72 | int rrdc_flush_if_daemon (const char *opt_daemon, const char *filename); 73 | 74 | int rrdc_fetch (const char *filename, 75 | const char *cf, 76 | time_t *ret_start, time_t *ret_end, 77 | unsigned long *ret_step, 78 | unsigned long *ret_ds_num, 79 | char ***ret_ds_names, 80 | rrd_value_t **ret_data); 81 | 82 | #else 83 | # define rrdc_flush_if_daemon(a,b) 0 84 | # define rrdc_connect(a) 0 85 | # define rrdc_is_connected(a) 0 86 | # define rrdc_flush(a) 0 87 | # define rrdc_update(a,b,c) 0 88 | #endif 89 | 90 | struct rrdc_stats_s 91 | { 92 | const char *name; 93 | uint16_t type; 94 | #define RRDC_STATS_TYPE_GAUGE 0x0001 95 | #define RRDC_STATS_TYPE_COUNTER 0x0002 96 | uint16_t flags; 97 | union 98 | { 99 | uint64_t counter; 100 | double gauge; 101 | } value; 102 | struct rrdc_stats_s *next; 103 | }; 104 | typedef struct rrdc_stats_s rrdc_stats_t; 105 | 106 | int rrdc_stats_get (rrdc_stats_t **ret_stats); 107 | void rrdc_stats_free (rrdc_stats_t *ret_stats); 108 | 109 | #endif /* __RRD_CLIENT_H */ 110 | /* 111 | * vim: set sw=2 sts=2 ts=8 et fdm=marker : 112 | */ 113 | -------------------------------------------------------------------------------- /src/rrd_flushcached.c: -------------------------------------------------------------------------------- 1 | /** 2 | * RRDTool - src/rrd_flushcached.c 3 | * Copyright (C) 2008 Florian octo Forster 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation; only version 2 of the License is applicable. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program; if not, write to the Free Software Foundation, Inc., 16 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | * 18 | * Authors: 19 | * Florian octo Forster 20 | **/ 21 | 22 | #include "rrd_tool.h" 23 | #include "rrd_client.h" 24 | 25 | int rrd_flushcached (int argc, char **argv) 26 | { 27 | char *opt_daemon = NULL; 28 | int status; 29 | int i; 30 | 31 | /* initialize getopt */ 32 | optind = 0; 33 | opterr = 0; 34 | 35 | while (42) 36 | { 37 | int opt; 38 | static struct option long_options[] = 39 | { 40 | {"daemon", required_argument, 0, 'd'}, 41 | {0, 0, 0, 0} 42 | }; 43 | 44 | opt = getopt_long(argc, argv, "d:", long_options, NULL); 45 | 46 | if (opt == -1) 47 | break; 48 | 49 | switch (opt) 50 | { 51 | case 'd': 52 | if (opt_daemon != NULL) 53 | free (opt_daemon); 54 | opt_daemon = strdup (optarg); 55 | if (opt_daemon == NULL) 56 | { 57 | rrd_set_error ("strdup failed."); 58 | return (-1); 59 | } 60 | break; 61 | 62 | default: 63 | rrd_set_error ("Usage: rrdtool %s [--daemon ] ", 64 | argv[0]); 65 | return (-1); 66 | } 67 | } /* while (42) */ 68 | 69 | if ((argc - optind) < 1) 70 | { 71 | rrd_set_error ("Usage: rrdtool %s [--daemon ] [ ...]", argv[0]); 72 | return (-1); 73 | } 74 | 75 | /* try to connect to rrdcached */ 76 | status = rrdc_connect(opt_daemon); 77 | if (status != 0) goto out; 78 | 79 | if (! rrdc_is_connected(opt_daemon)) 80 | { 81 | rrd_set_error ("Daemon address unknown. Please use the \"--daemon\" " 82 | "option to set an address on the command line or set the " 83 | "\"%s\" environment variable.", 84 | ENV_RRDCACHED_ADDRESS); 85 | status = -1; 86 | goto out; 87 | } 88 | 89 | status = 0; 90 | for (i = optind; i < argc; i++) 91 | { 92 | status = rrdc_flush(argv[i]); 93 | if (status) 94 | { 95 | char *error; 96 | int remaining; 97 | 98 | error = strdup(rrd_get_error()); 99 | remaining = argc - optind - 1; 100 | 101 | rrd_set_error("Flushing of file \"%s\" failed: %s. Skipping " 102 | "remaining %i file%s.", argv[i], 103 | ((! error) || (*error == '\0')) ? "unknown error" : error, 104 | remaining, (remaining == 1) ? "" : "s"); 105 | free(error); 106 | break; 107 | } 108 | } 109 | 110 | out: 111 | if (opt_daemon) free(opt_daemon); 112 | 113 | return status; 114 | } /* int rrd_flush */ 115 | 116 | /* 117 | * vim: set sw=4 sts=4 et fdm=marker : 118 | */ 119 | -------------------------------------------------------------------------------- /src/rrd_thread_safe.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * RRDtool 1.4.3 Copyright by Tobi Oetiker, 1997-2010 3 | * This file: Copyright 2003 Peter Stamfest 4 | * & Tobias Oetiker 5 | * Distributed under the GPL 6 | ***************************************************************************** 7 | * rrd_thread_safe.c Contains routines used when thread safety is required 8 | ***************************************************************************** 9 | * $Id$ 10 | *************************************************************************** */ 11 | 12 | #include 13 | #include 14 | /* #include */ 15 | #include "rrd.h" 16 | #include "rrd_tool.h" 17 | 18 | /* Key for the thread-specific rrd_context */ 19 | static pthread_key_t context_key; 20 | 21 | /* Once-only initialisation of the key */ 22 | static pthread_once_t context_key_once = PTHREAD_ONCE_INIT; 23 | 24 | /* Free the thread-specific rrd_context - we might actually use 25 | rrd_free_context instead... 26 | */ 27 | static void context_destroy_context( 28 | void *ctx_) 29 | { 30 | rrd_context_t *ctx = ctx_; 31 | 32 | if (ctx) 33 | rrd_free_context(ctx); 34 | } 35 | 36 | /* Allocate the key */ 37 | static void context_get_key( 38 | void) 39 | { 40 | pthread_key_create(&context_key, context_destroy_context); 41 | } 42 | 43 | rrd_context_t *rrd_get_context( 44 | void) 45 | { 46 | rrd_context_t *ctx; 47 | 48 | pthread_once(&context_key_once, context_get_key); 49 | ctx = pthread_getspecific(context_key); 50 | if (!ctx) { 51 | ctx = rrd_new_context(); 52 | pthread_setspecific(context_key, ctx); 53 | } 54 | return ctx; 55 | } 56 | 57 | #ifdef HAVE_STRERROR_R 58 | const char *rrd_strerror( 59 | int err) 60 | { 61 | rrd_context_t *ctx = rrd_get_context(); 62 | char *ret = "unknown error"; 63 | 64 | *ctx->lib_errstr = '\0'; 65 | 66 | /* Even though POSIX/XSI requires "strerror_r" to return an "int", some 67 | * systems (e.g. the GNU libc) return a "char *" _and_ ignore the second 68 | * argument ... -tokkee */ 69 | #ifdef STRERROR_R_CHAR_P 70 | ret = strerror_r(err, ctx->lib_errstr, sizeof(ctx->lib_errstr)); 71 | if ((! ret) || (*ret == '\0')) { 72 | if (*ctx->lib_errstr != '\0') 73 | ret = ctx->lib_errstr; 74 | else { 75 | /* according to the manpage this should not happen - 76 | let's handle it somehow sanely anyway */ 77 | snprintf(ctx->lib_errstr, sizeof(ctx->lib_errstr), 78 | "unknown error %i - strerror_r did not return anything", 79 | err); 80 | ctx->lib_errstr[sizeof(ctx->lib_errstr) - 1] = '\0'; 81 | ret = ctx->lib_errstr; 82 | } 83 | } 84 | #else /* ! STRERROR_R_CHAR_P */ 85 | if (strerror_r(err, ctx->lib_errstr, sizeof(ctx->lib_errstr))) { 86 | snprintf(ctx->lib_errstr, sizeof(ctx->lib_errstr), 87 | "unknown error %i - strerror_r returned with errno = %i", 88 | err, errno); 89 | ctx->lib_errstr[sizeof(ctx->lib_errstr) - 1] = '\0'; 90 | } 91 | ret = ctx->lib_errstr; 92 | #endif 93 | return ret; 94 | } 95 | #else 96 | #undef strerror 97 | const char *rrd_strerror( 98 | int err) 99 | { 100 | static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; 101 | rrd_context_t *ctx; 102 | 103 | ctx = rrd_get_context(); 104 | pthread_mutex_lock(&mtx); 105 | strncpy(ctx->lib_errstr, strerror(err), sizeof(ctx->lib_errstr)); 106 | ctx->lib_errstr[sizeof(ctx->lib_errstr) - 1] = '\0'; 107 | pthread_mutex_unlock(&mtx); 108 | return ctx->lib_errstr; 109 | } 110 | #endif 111 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | #AUTOMAKE_OPTIONS = foreign 4 | # 5 | #ACLOCAL_M4 = $(top_srcdir)/config/aclocal.m4 6 | #AUTOHEADER = @AUTOHEADER@ --localdir=$(top_srcdir)/config 7 | 8 | if STATIC_PROGRAMS 9 | AM_LDFLAGS = -all-static 10 | endif 11 | 12 | INCLUDES = -DLOCALEDIR="\"$(datadir)/locale\"" 13 | RRD_DEFAULT_FONT=@RRD_DEFAULT_FONT@ 14 | AM_CPPFLAGS = -DRRD_DEFAULT_FONT=\"$(RRD_DEFAULT_FONT)\" -DNUMVERS=@NUMVERS@ 15 | AM_CFLAGS = @CFLAGS@ 16 | ## no including this by default @WERROR@ 17 | 18 | UPD_C_FILES = \ 19 | rrd_parsetime.c \ 20 | rrd_hw.c \ 21 | rrd_hw_math.c \ 22 | rrd_hw_update.c \ 23 | rrd_diff.c \ 24 | rrd_format.c \ 25 | rrd_info.c \ 26 | rrd_error.c \ 27 | rrd_open.c \ 28 | rrd_client.c \ 29 | rrd_nan_inf.c \ 30 | rrd_rpncalc.c \ 31 | rrd_utils.c \ 32 | rrd_update.c 33 | 34 | RRD_C_FILES = \ 35 | hash_32.c \ 36 | pngsize.c \ 37 | rrd_create.c \ 38 | rrd_graph.c \ 39 | rrd_graph_helper.c \ 40 | rrd_version.c \ 41 | rrd_last.c \ 42 | rrd_lastupdate.c \ 43 | rrd_first.c \ 44 | rrd_restore.c \ 45 | rrd_xport.c \ 46 | rrd_gfx.c \ 47 | rrd_dump.c \ 48 | rrd_flushcached.c \ 49 | rrd_fetch.c \ 50 | rrd_resize.c \ 51 | rrd_tune.c 52 | 53 | noinst_HEADERS = \ 54 | unused.h \ 55 | gettext.h \ 56 | rrd_getopt.h rrd_parsetime.h \ 57 | rrd_config_bottom.h rrd_i18n.h \ 58 | rrd_format.h rrd_tool.h rrd_xport.h rrd.h rrd_rpncalc.h \ 59 | rrd_hw.h rrd_hw_math.h rrd_hw_update.h \ 60 | fnv.h rrd_graph.h \ 61 | rrd_is_thread_safe.h 62 | 63 | if BUILD_LIBDBI 64 | RRD_C_FILES += rrd_fetch_libdbi.c 65 | endif 66 | 67 | if BUILD_GETOPT 68 | noinst_HEADERS += rrd_getopt.h 69 | UPD_C_FILES += rrd_getopt.c rrd_getopt1.c 70 | endif 71 | 72 | noinst_LTLIBRARIES = librrdupd.la 73 | 74 | lib_LTLIBRARIES = librrd.la 75 | if BUILD_MULTITHREAD 76 | lib_LTLIBRARIES += librrd_th.la 77 | endif 78 | 79 | librrdupd_la_SOURCES = $(UPD_C_FILES) rrd_not_thread_safe.c 80 | librrdupd_la_LIBADD = $(CORE_LIBS) 81 | 82 | librrd_la_SOURCES = $(RRD_C_FILES) 83 | librrd_la_DEPENDENCIES = librrdupd.la librrd.sym 84 | librrd_la_LIBADD = librrdupd.la $(ALL_LIBS) 85 | librrd_la_LDFLAGS = -version-info @LIBVERS@ 86 | librrd_la_LDFLAGS += -export-symbols librrd.sym 87 | 88 | librrd_th_la_SOURCES = $(UPD_C_FILES) $(RRD_C_FILES) rrd_thread_safe.c 89 | librrd_th_la_DEPENDENCIES = librrd.sym 90 | librrd_th_la_CFLAGS = $(AM_CFLAGS) $(MULTITHREAD_CFLAGS) 91 | librrd_th_la_LDFLAGS = $(MULTITHREAD_LDFLAGS) -version-info @LIBVERS@ 92 | librrd_th_la_LDFLAGS += -export-symbols librrd.sym 93 | librrd_th_la_LIBADD = $(ALL_LIBS) 94 | 95 | include_HEADERS = rrd.h rrd_format.h rrd_client.h 96 | 97 | bin_PROGRAMS = rrdtool rrdupdate rrdcached 98 | 99 | if BUILD_RRDCGI 100 | bin_PROGRAMS += rrdcgi 101 | endif 102 | 103 | rrdcgi_SOURCES = rrd_cgi.c 104 | rrdcgi_LDADD = librrd.la 105 | 106 | rrdupdate_SOURCES = rrdupdate.c 107 | rrdupdate_LDADD = librrdupd.la 108 | 109 | rrdtool_SOURCES = rrd_tool.c 110 | rrdtool_DEPENDENCIES = librrd.la 111 | rrdtool_LDADD = librrd.la 112 | 113 | rrdcached_SOURCES = rrd_daemon.c 114 | rrdcached_DEPENDENCIES = librrd_th.la 115 | rrdcached_CPPFLAGS = -DVERSION='"$(VERSION)"' -DLOCALSTATEDIR='"$(localstatedir)"' 116 | rrdcached_LDADD = librrd_th.la 117 | 118 | pkgconfigdir = $(libdir)/pkgconfig 119 | pkgconfig_DATA = librrd.pc 120 | 121 | # strftime is here because we do not usually need it. unices have propper 122 | # iso date support 123 | EXTRA_DIST= librrd.pc.in strftime.c strftime.h rrd_getopt.c rrd_getopt1.c rrd_getopt.h \ 124 | win32comp.c rrd_thread_safe_nt.c get_ver.awk librrd.sym.in.in plbasename.c plbasename.h 125 | 126 | 127 | librrd.sym: librrd.sym.in 128 | $(AM_V_GEN)grep -v LIBC_HAS_GETOPT_LONG librrd.sym.in >$@ 129 | -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- 1 | $Id$ 2 | RRDTOOL - Round Robin Database Tool 3 | A tool for fast logging of numerical data graphical display 4 | of this data. 5 | 6 | Copyright (c) 1998-2009 Tobias Oetiker 7 | All rights reserved. 8 | 9 | GNU GPL License 10 | =============== 11 | 12 | This program is free software; you can redistribute it and/or modify it 13 | under the terms of the GNU General Public License as published by the Free 14 | Software Foundation; either version 2 of the License, or (at your option) 15 | any later version. 16 | 17 | This program is distributed in the hope that it will be useful, but WITHOUT 18 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 20 | more details. 21 | 22 | You should have received a copy of the GNU General Public License along 23 | with this program; if not, write to the Free Software Foundation, Inc., 24 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 25 | 26 | FLOSS License Exception 27 | ======================= 28 | (Adapted from http://www.mysql.com/company/legal/licensing/foss-exception.html) 29 | 30 | I want specified Free/Libre and Open Source Software ("FLOSS") 31 | applications to be able to use specified GPL-licensed RRDtool 32 | libraries (the "Program") despite the fact that not all FLOSS licenses are 33 | compatible with version 2 of the GNU General Public License (the "GPL"). 34 | 35 | As a special exception to the terms and conditions of version 2.0 of the GPL: 36 | 37 | You are free to distribute a Derivative Work that is formed entirely from 38 | the Program and one or more works (each, a "FLOSS Work") licensed under one 39 | or more of the licenses listed below, as long as: 40 | 41 | 1. You obey the GPL in all respects for the Program and the Derivative 42 | Work, except for identifiable sections of the Derivative Work which are 43 | not derived from the Program, and which can reasonably be considered 44 | independent and separate works in themselves, 45 | 46 | 2. all identifiable sections of the Derivative Work which are not derived 47 | from the Program, and which can reasonably be considered independent and 48 | separate works in themselves, 49 | 50 | 1. are distributed subject to one of the FLOSS licenses listed 51 | below, and 52 | 53 | 2. the object code or executable form of those sections are 54 | accompanied by the complete corresponding machine-readable source 55 | code for those sections on the same medium and under the same FLOSS 56 | license as the corresponding object code or executable forms of 57 | those sections, and 58 | 59 | 3. any works which are aggregated with the Program or with a Derivative 60 | Work on a volume of a storage or distribution medium in accordance with 61 | the GPL, can reasonably be considered independent and separate works in 62 | themselves which are not derivatives of either the Program, a Derivative 63 | Work or a FLOSS Work. 64 | 65 | If the above conditions are not met, then the Program may only be copied, 66 | modified, distributed or used under the terms and conditions of the GPL. 67 | 68 | FLOSS License List 69 | ================== 70 | License name Version(s)/Copyright Date 71 | Academic Free License 2.0 72 | Apache Software License 1.0/1.1/2.0 73 | Apple Public Source License 2.0 74 | Artistic license From Perl 5.8.0 75 | BSD license "July 22 1999" 76 | Common Public License 1.0 77 | GNU Library or "Lesser" General Public License (LGPL) 2.0/2.1 78 | IBM Public License, Version 1.0 79 | Jabber Open Source License 1.0 80 | MIT License (As listed in file MIT-License.txt) - 81 | Mozilla Public License (MPL) 1.0/1.1 82 | Open Software License 2.0 83 | OpenSSL license (with original SSLeay license) "2003" ("1998") 84 | PHP License 3.01 85 | Python license (CNRI Python License) - 86 | Python Software Foundation License 2.1.1 87 | Sleepycat License "1999" 88 | W3C License "2001" 89 | X11 License "2001" 90 | Zlib/libpng License - 91 | Zope Public License 2.0/2.1 92 | -------------------------------------------------------------------------------- /src/rrd_diff.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * RRDtool 1.4.3 Copyright by Tobi Oetiker, 1997-2010 3 | * This code is stolen from rateup (mrtg-2.x) by Dave Rand 4 | ***************************************************************************** 5 | * diff calculate the difference between two very long integers available as 6 | * strings 7 | ***************************************************************************** 8 | * $Id$ 9 | * $Log$ 10 | * Revision 1.4 2003/03/10 00:30:34 oetiker 11 | * handle cases with two negative numbers 12 | * -- Sasha Mikheev 13 | * 14 | * Revision 1.3 2002/04/01 18:31:22 oetiker 15 | * "!" takes a higher preference than "||" this means rrd_update N:: would 16 | * segfault -- Oliver Cook 17 | * 18 | * Revision 1.2 2002/02/01 20:34:49 oetiker 19 | * fixed version number and date/time 20 | * 21 | * Revision 1.1.1.1 2001/02/25 22:25:05 oetiker 22 | * checkin 23 | * 24 | * Revision 1.1 1998/10/08 18:21:45 oetiker 25 | * Initial revision 26 | * 27 | * Revision 1.3 1998/02/06 21:10:52 oetiker 28 | * removed max define .. it is now in rrd_tool.h 29 | * 30 | * Revision 1.2 1997/12/07 20:38:03 oetiker 31 | * ansified 32 | * 33 | * Revision 1.1 1997/11/28 23:31:59 oetiker 34 | * Initial revision 35 | * 36 | *****************************************************************************/ 37 | 38 | #include 39 | #include "rrd_tool.h" 40 | 41 | double rrd_diff( 42 | char *a, 43 | char *b) 44 | { 45 | char res[LAST_DS_LEN + 1], *a1, *b1, *r1, *fix; 46 | int c, x, m; 47 | char a_neg = 0, b_neg = 0; 48 | double result; 49 | 50 | while (!(isdigit((int) *a) || *a == 0)) { 51 | if (*a == '-') 52 | a_neg = 1; 53 | a++; 54 | } 55 | fix = a; 56 | while (isdigit((int) *fix)) 57 | fix++; 58 | *fix = 0; /* maybe there is some non digit data in the string */ 59 | while (!(isdigit((int) *b) || *b == 0)) { 60 | if (*b == '-') 61 | b_neg = 1; 62 | b++; 63 | } 64 | fix = b; 65 | while (isdigit((int) *fix)) 66 | fix++; 67 | *fix = 0; /* maybe there is some non digit data in the string */ 68 | if (!isdigit((int) *a) || !isdigit((int) *b)) 69 | return DNAN; 70 | if (a_neg + b_neg == 1) /* can not handle numbers with different signs yet */ 71 | return DNAN; 72 | a1 = &a[strlen(a) - 1]; 73 | m = max(strlen(a), strlen(b)); 74 | if (m > LAST_DS_LEN) 75 | return DNAN; /* result string too short */ 76 | 77 | r1 = &res[m + 1]; 78 | for (b1 = res; b1 <= r1; b1++) 79 | *b1 = ' '; 80 | b1 = &b[strlen(b) - 1]; 81 | r1[1] = 0; /* Null terminate result */ 82 | c = 0; 83 | for (x = 0; x < m; x++) { 84 | if (a1 >= a && b1 >= b) { 85 | *r1 = ((*a1 - c) - *b1) + '0'; 86 | } else if (a1 >= a) { 87 | *r1 = (*a1 - c); 88 | } else { 89 | *r1 = ('0' - *b1 - c) + '0'; 90 | } 91 | if (*r1 < '0') { 92 | *r1 += 10; 93 | c = 1; 94 | } else if (*r1 > '9') { /* 0 - 10 */ 95 | *r1 -= 10; 96 | c = 1; 97 | } else { 98 | c = 0; 99 | } 100 | a1--; 101 | b1--; 102 | r1--; 103 | } 104 | if (c) { 105 | r1 = &res[m + 1]; 106 | for (x = 0; isdigit((int) *r1) && x < m; x++, r1--) { 107 | *r1 = ('9' - *r1 + c) + '0'; 108 | if (*r1 > '9') { 109 | *r1 -= 10; 110 | c = 1; 111 | } else { 112 | c = 0; 113 | } 114 | } 115 | result = -atof(res); 116 | } else 117 | result = atof(res); 118 | 119 | if (a_neg + b_neg == 2) /* both are negatives, reverse sign */ 120 | result = -result; 121 | 122 | return result; 123 | } 124 | -------------------------------------------------------------------------------- /src/rrd_hw_math.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * rrd_hw_math.h Math functions for Holt-Winters computations 3 | *****************************************************************************/ 4 | 5 | #include "rrd.h" 6 | #include "rrd_format.h" 7 | 8 | /* since /usr/include/bits/mathcalls.h:265 defines gamma already */ 9 | #define gamma hw_gamma 10 | 11 | /***************************************************************************** 12 | * Functions for additive Holt-Winters 13 | *****************************************************************************/ 14 | 15 | rrd_value_t hw_additive_calculate_prediction( 16 | rrd_value_t intercept, 17 | rrd_value_t slope, 18 | int null_count, 19 | rrd_value_t seasonal_coef); 20 | 21 | rrd_value_t hw_additive_calculate_intercept( 22 | rrd_value_t alpha, 23 | rrd_value_t scratch, 24 | rrd_value_t seasonal_coef, 25 | unival *coefs); 26 | 27 | rrd_value_t hw_additive_calculate_seasonality( 28 | rrd_value_t gamma, 29 | rrd_value_t scratch, 30 | rrd_value_t intercept, 31 | rrd_value_t seasonal_coef); 32 | 33 | rrd_value_t hw_additive_init_seasonality( 34 | rrd_value_t seasonal_coef, 35 | rrd_value_t intercept); 36 | 37 | /***************************************************************************** 38 | * Functions for multiplicative Holt-Winters 39 | *****************************************************************************/ 40 | 41 | rrd_value_t hw_multiplicative_calculate_prediction( 42 | rrd_value_t intercept, 43 | rrd_value_t slope, 44 | int null_count, 45 | rrd_value_t seasonal_coef); 46 | 47 | rrd_value_t hw_multiplicative_calculate_intercept( 48 | rrd_value_t alpha, 49 | rrd_value_t scratch, 50 | rrd_value_t seasonal_coef, 51 | unival *coefs); 52 | 53 | rrd_value_t hw_multiplicative_calculate_seasonality( 54 | rrd_value_t gamma, 55 | rrd_value_t scratch, 56 | rrd_value_t intercept, 57 | rrd_value_t seasonal_coef); 58 | 59 | rrd_value_t hw_multiplicative_init_seasonality( 60 | rrd_value_t seasonal_coef, 61 | rrd_value_t intercept); 62 | 63 | /***************************************************************************** 64 | * Math functions common to additive and multiplicative Holt-Winters 65 | *****************************************************************************/ 66 | 67 | rrd_value_t hw_calculate_slope( 68 | rrd_value_t beta, 69 | unival *coefs); 70 | 71 | rrd_value_t hw_calculate_seasonal_deviation( 72 | rrd_value_t gamma, 73 | rrd_value_t prediction, 74 | rrd_value_t observed, 75 | rrd_value_t last); 76 | 77 | rrd_value_t hw_init_seasonal_deviation( 78 | rrd_value_t prediction, 79 | rrd_value_t observed); 80 | 81 | 82 | /* Function container */ 83 | 84 | typedef struct hw_functions_t { 85 | rrd_value_t ( 86 | *predict) ( 87 | rrd_value_t intercept, 88 | rrd_value_t slope, 89 | int null_count, 90 | rrd_value_t seasonal_coef); 91 | 92 | rrd_value_t ( 93 | *intercept) ( 94 | rrd_value_t alpha, 95 | rrd_value_t observed, 96 | rrd_value_t seasonal_coef, 97 | unival *coefs); 98 | 99 | rrd_value_t ( 100 | *slope) ( 101 | rrd_value_t beta, 102 | unival *coefs); 103 | 104 | rrd_value_t ( 105 | *seasonality) ( 106 | rrd_value_t gamma, 107 | rrd_value_t observed, 108 | rrd_value_t intercept, 109 | rrd_value_t seasonal_coef); 110 | 111 | rrd_value_t ( 112 | *init_seasonality) ( 113 | rrd_value_t seasonal_coef, 114 | rrd_value_t intercept); 115 | 116 | rrd_value_t ( 117 | *seasonal_deviation) ( 118 | rrd_value_t gamma, 119 | rrd_value_t prediction, 120 | rrd_value_t observed, 121 | rrd_value_t last); 122 | 123 | rrd_value_t ( 124 | *init_seasonal_deviation) ( 125 | rrd_value_t prediction, 126 | rrd_value_t observed); 127 | 128 | rrd_value_t identity; 129 | } hw_functions_t; 130 | 131 | 132 | #undef gamma 133 | -------------------------------------------------------------------------------- /examples/rrdcached/rrdcached-size.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | rrdcached-size.pl - estimate the IO and memory requirements for rrdcached 6 | 7 | =head1 SYNOPSIS 8 | 9 | B 10 | [B<-rrds>EI] 11 | [B<-step>EI] 12 | [B<-update>EI] 13 | [B<-file>EI] 14 | [B<-io>EI] 15 | [B<-w>EI] 16 | [B<-f>EI] 17 | [B<-pagesize>EI] 18 | 19 | =head1 OPTIONS 20 | 21 | =over 4 22 | 23 | =item B<-rrds> I 24 | 25 | Specify the number of RRDs in the working set. 26 | 27 | =item B<-step> I 28 | 29 | Specify the RRD step value for each file. 30 | 31 | =item B<-update> I 32 | 33 | Average update string length. For this calculation, the time value must 34 | be specified as a C, not C. For example, this update string 35 | would lead to B<-update>EI<43> : 36 | 37 | 1226936851:0:0:101113914:0:0:0:25814373:0:0 38 | 39 | =item B<-file> I 40 | 41 | Specify the average file name length. For this calculation, use the full 42 | path of the file. 43 | 44 | =item B<-io> I 45 | 46 | Specify the number of RRD files that your system can write per second. 47 | 48 | =item B<-w> I 49 | 50 | Specifies the B<-w> timer used with rrdcached. For more information, see 51 | the B documentation. 52 | 53 | =item B<-f> I 54 | 55 | Specifies the B<-f> timer used with rrdcached. For more information, see 56 | the B documentation. 57 | 58 | =item B<-pagesize> I 59 | 60 | Manually specify the system page size, in case it is not detected 61 | properly. 62 | 63 | =back 64 | 65 | =cut 66 | 67 | use strict; 68 | use warnings; 69 | 70 | my $filename_len = 60; 71 | my $update_len = 128; 72 | my $rrds = 100; 73 | my $step = 300; 74 | my $rrd_per_sec = 200; 75 | my $rrdc_write = 300; 76 | my $rrdc_flush = 3600; 77 | my $pagesize = `pagesize` || 4096; 78 | 79 | ################################################################# 80 | 81 | use Getopt::Long; 82 | GetOptions('rrds=i' => \$rrds, 83 | 'step=i' => \$step, 84 | 'update=i' => \$update_len, 85 | 'file=i' => \$filename_len, 86 | 'io=i' => \$rrd_per_sec, 87 | 'w=i' => \$rrdc_write, 88 | 'f=i' => \$rrdc_flush, 89 | 'pagesize=i' => \$pagesize, 90 | 'h' => \&usage, 91 | ) 92 | or die "Options failure"; 93 | 94 | @ARGV and die "Extra args: @ARGV\n"; 95 | 96 | ################################################################# 97 | 98 | my $MEG = 1024*1024; 99 | 100 | my $write_time = int($rrds / $rrd_per_sec); 101 | my $write_busy = int(100 * $write_time / $rrdc_write); 102 | my $buffered_pdp = $rrdc_write / $step; 103 | 104 | my $max_ram 105 | = $rrds 106 | * ($filename_len 107 | + ( $rrdc_write / $step ) * $update_len) 108 | / $MEG; 109 | 110 | my $journal_size 111 | = $rrds 112 | * (length("update") + $filename_len + $update_len + 3) 113 | * ($rrdc_flush/$step) 114 | * 2 # 2 logs 115 | / $MEG; 116 | 117 | my $journal_rate = (($journal_size*$MEG/2))/$rrdc_flush; 118 | my $journal_page_rate = $journal_rate / $pagesize; 119 | 120 | $_ = sprintf("%.1f", $_) 121 | for ($write_time, 122 | $write_busy, 123 | $buffered_pdp, 124 | $max_ram, 125 | $journal_size, 126 | $journal_rate, 127 | $journal_page_rate, 128 | ); 129 | 130 | print <<"EOF"; 131 | RRD files : $rrds files 132 | RRD step : $step seconds 133 | Update length : $update_len bytes 134 | IO writes/sec : $rrd_per_sec rrd/sec 135 | write timer : $rrdc_write seconds 136 | flush timer : $rrdc_flush seconds 137 | ----------------------------------------------------------------- 138 | 139 | Time to write all RRDs: $write_time sec ($write_busy\% busy) 140 | 141 | $buffered_pdp PDPs will be buffered per file 142 | 143 | RAM usage: $max_ram MB 144 | 145 | Journal size: $journal_size MB (total size for two journals) 146 | 147 | Journal write rate: $journal_page_rate page/sec ($journal_rate byte/sec) 148 | EOF 149 | 150 | sub usage { 151 | system("perldoc $0"); 152 | exit(1); 153 | } 154 | -------------------------------------------------------------------------------- /src/rrd_error.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * RRDtool 1.4.3 Copyright by Tobi Oetiker, 1997-2010 3 | ***************************************************************************** 4 | * rrd_error.c Common Header File 5 | ***************************************************************************** 6 | * $Id$ 7 | * $Log$ 8 | * Revision 1.4 2003/02/22 21:57:03 oetiker 9 | * a patch to avoid a memory leak and a Makefile.am patch to 10 | * distribute all required source files -- Peter Stamfest 11 | * 12 | * Revision 1.3 2003/02/13 07:05:27 oetiker 13 | * Find attached the patch I promised to send to you. Please note that there 14 | * are three new source files (src/rrd_is_thread_safe.h, src/rrd_thread_safe.c 15 | * and src/rrd_not_thread_safe.c) and the introduction of librrd_th. This 16 | * library is identical to librrd, but it contains support code for per-thread 17 | * global variables currently used for error information only. This is similar 18 | * to how errno per-thread variables are implemented. librrd_th must be linked 19 | * alongside of libpthred 20 | * 21 | * There is also a new file "THREADS", holding some documentation. 22 | * 23 | * -- Peter Stamfest 24 | * 25 | * Revision 1.2 2002/02/01 20:34:49 oetiker 26 | * fixed version number and date/time 27 | * 28 | * Revision 1.1.1.1 2001/02/25 22:25:05 oetiker 29 | * checkin 30 | * 31 | *************************************************************************** */ 32 | 33 | #include 34 | #include 35 | 36 | #include "rrd_tool.h" 37 | 38 | #define MAXLEN 4096 39 | #define ERRBUFLEN 256 40 | #define CTX (rrd_get_context()) 41 | 42 | void rrd_set_error( 43 | char *fmt, 44 | ...) 45 | { 46 | va_list argp; 47 | 48 | rrd_clear_error(); 49 | va_start(argp, fmt); 50 | #ifdef HAVE_VSNPRINTF 51 | vsnprintf(CTX->rrd_error, sizeof(CTX->rrd_error), fmt, argp); 52 | #else 53 | vsprintf(CTX->rrd_error, fmt, argp); 54 | #endif 55 | va_end(argp); 56 | } 57 | 58 | int rrd_test_error( 59 | void) 60 | { 61 | return CTX->rrd_error[0] != '\0'; 62 | } 63 | 64 | void rrd_clear_error( 65 | void) 66 | { 67 | CTX->rrd_error[0] = '\0'; 68 | } 69 | 70 | char *rrd_get_error( 71 | void) 72 | { 73 | return CTX->rrd_error; 74 | } 75 | 76 | #if 0 77 | /* PS: Keep this stuff around, maybe we want it again if we use 78 | rrd_contexts to really associate them with single RRD files and 79 | operations on them... Then a single thread may use more than one 80 | context. Using these functions would require to change each and 81 | every function containing any of the non _r versions... */ 82 | void rrd_set_error_r( 83 | rrd_context_t * rrd_ctx, 84 | char *fmt, 85 | ...) 86 | { 87 | va_list argp; 88 | 89 | rrd_clear_error_r(rrd_ctx); 90 | va_start(argp, fmt); 91 | #ifdef HAVE_VSNPRINTF 92 | vsnprintf(rrd_ctx->rrd_error, sizeof(rrd_ctx->rrd_error), fmt, argp); 93 | rrd_ctx->rrd_error[sizeof(rrd_ctx->rrd_error) - 1] = '\0'; 94 | #else 95 | vsprintf(rrd_ctx->rrd_error, fmt, argp); 96 | #endif 97 | va_end(argp); 98 | } 99 | 100 | int rrd_test_error_r( 101 | rrd_context_t * rrd_ctx) 102 | { 103 | return rrd_ctx->rrd_error[0] != '\0'; 104 | } 105 | 106 | void rrd_clear_error_r( 107 | rrd_context_t * rrd_ctx) 108 | { 109 | rrd_ctx->rrd_error[0] = '\0'; 110 | } 111 | 112 | char *rrd_get_error_r( 113 | rrd_context_t * rrd_ctx) 114 | { 115 | return rrd_ctx->rrd_error; 116 | } 117 | #endif 118 | 119 | /* PS: Should we move this to some other file? It is not really error 120 | related. */ 121 | rrd_context_t *rrd_new_context( 122 | void) 123 | { 124 | rrd_context_t *rrd_ctx = (rrd_context_t *) malloc(sizeof(rrd_context_t)); 125 | 126 | if (!rrd_ctx) { 127 | return NULL; 128 | } 129 | 130 | rrd_ctx->rrd_error[0] = '\0'; 131 | rrd_ctx->lib_errstr[0] = '\0'; 132 | return rrd_ctx; 133 | } 134 | 135 | void rrd_free_context( 136 | rrd_context_t * rrd_ctx) 137 | { 138 | if (rrd_ctx) { 139 | free(rrd_ctx); 140 | } 141 | } 142 | 143 | #if 0 144 | void rrd_globalize_error( 145 | rrd_context_t * rrd_ctx) 146 | { 147 | if (rrd_ctx) { 148 | rrd_set_error(rrd_ctx->rrd_error); 149 | } 150 | } 151 | #endif 152 | -------------------------------------------------------------------------------- /win32/rrdtool.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="rrdtool" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Console Application" 0x0103 6 | 7 | CFG=rrdtool - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "rrdtool.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "rrdtool.mak" CFG="rrdtool - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "rrdtool - Win32 Release" (based on "Win32 (x86) Console Application") 21 | !MESSAGE "rrdtool - Win32 Debug" (based on "Win32 (x86) Console Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "rrdtool - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "rrdtool_" 36 | # PROP BASE Intermediate_Dir "rrdtool_" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "toolrelease" 41 | # PROP Intermediate_Dir "toolrelease" 42 | # PROP Ignore_Export_Lib 0 43 | # PROP Target_Dir "" 44 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 45 | # ADD CPP /nologo /MD /W3 /GX /I "../src" /I "../../zlib-1.2.3" /I "../../libpng-1.2.16" /I "../../libart_lgpl-2.3.17" /I "../../freetype-2.3.1/include" /D "HAVE_CONFIG_H" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_CTYPE_DISABLE_MACROS" /FD /c 46 | # SUBTRACT CPP /YX 47 | # ADD BASE RSC /l 0x100c /d "NDEBUG" 48 | # ADD RSC /l 0x409 /d "NDEBUG" 49 | BSC32=bscmake.exe 50 | # ADD BASE BSC32 /nologo 51 | # ADD BSC32 /nologo 52 | LINK32=link.exe 53 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 54 | # ADD LINK32 libpng.lib zlib.lib libart.lib freetype231MT.lib kernel32.lib user32.lib /nologo /subsystem:console /incremental:yes /debug /machine:I386 /libpath:"../../libpng-1.2.16/projects/visualc6/Win32_LIB_Release" /libpath:"../../zlib-1.2.3" /libpath:"../../libart_lgpl-2.3.17/win32/release" /libpath:"../../freetype-2.3.1/objs" 55 | 56 | !ELSEIF "$(CFG)" == "rrdtool - Win32 Debug" 57 | 58 | # PROP BASE Use_MFC 0 59 | # PROP BASE Use_Debug_Libraries 1 60 | # PROP BASE Output_Dir "rrdtool0" 61 | # PROP BASE Intermediate_Dir "rrdtool0" 62 | # PROP BASE Target_Dir "" 63 | # PROP Use_MFC 0 64 | # PROP Use_Debug_Libraries 1 65 | # PROP Output_Dir "tooldebug" 66 | # PROP Intermediate_Dir "tooldebug" 67 | # PROP Ignore_Export_Lib 0 68 | # PROP Target_Dir "" 69 | # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 70 | # ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "../src" /I "../../zlib-1.2.3" /I "../../libpng-1.2.16" /I "../../libart_lgpl-2.3.17" /I "../../freetype-2.3.1/include" /D "HAVE_CONFIG_H" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "_CTYPE_DISABLE_MACROS" /FR /FD /c 71 | # SUBTRACT CPP /YX 72 | # ADD BASE RSC /l 0x100c /d "_DEBUG" 73 | # ADD RSC /l 0x409 /d "_DEBUG" 74 | BSC32=bscmake.exe 75 | # ADD BASE BSC32 /nologo 76 | # ADD BSC32 /nologo /o"rrdtool.bsc" 77 | LINK32=link.exe 78 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept 79 | # ADD LINK32 libpng.lib zlib.lib libart.lib freetype231MT.lib kernel32.lib user32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"../../libpng-1.2.16/projects/visualc6/Win32_LIB_Release" /libpath:"../../zlib-1.2.3" /libpath:"../../libart_lgpl-2.3.17/win32/release" /libpath:"../../freetype-2.3.1/objs" 80 | 81 | !ENDIF 82 | 83 | # Begin Target 84 | 85 | # Name "rrdtool - Win32 Release" 86 | # Name "rrdtool - Win32 Debug" 87 | # Begin Source File 88 | 89 | SOURCE=..\src\rrd_tool.c 90 | # End Source File 91 | # End Target 92 | # End Project 93 | -------------------------------------------------------------------------------- /doc/rrdthreads.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | rrdthreads - Provisions for linking the RRD library to use in multi-threaded programs 4 | 5 | =head1 SYNOPSIS 6 | 7 | Using librrd in multi-threaded programs requires some extra 8 | precautions, as the RRD library in its original form was not 9 | thread-safe at all. This document describes requirements and pitfalls 10 | on the way to use the multi-threaded version of librrd in your own 11 | programs. It also gives hints for future RRD development to keep the 12 | library thread-safe. 13 | 14 | Currently only some RRD operations are implemented in a thread-safe 15 | way. They all end in the usual "C<_r>" suffix. 16 | 17 | =head1 DESCRIPTION 18 | 19 | In order to use librrd in multi-threaded programs you must: 20 | 21 | =over 22 | 23 | =item * 24 | 25 | Link with F instead of F (use C<-lrrd_th> when 26 | linking) 27 | 28 | =item * 29 | 30 | Use the "C<_r>" functions instead of the normal API-functions 31 | 32 | =item * 33 | 34 | Do not use any at-style time specifications. Parsing of such time 35 | specifications is terribly non-thread-safe. 36 | 37 | =item * 38 | 39 | Never use non *C<_r> functions unless it is explicitly documented that 40 | the function is tread-safe. 41 | 42 | =item * 43 | 44 | Every thread SHOULD call C before its first call to 45 | any C function in order to set up thread specific data. This 46 | is not strictly required, but it is the only way to test if memory 47 | allocation can be done by this function. Otherwise the program may die 48 | with a SIGSEGV in a low-memory situation. 49 | 50 | =item * 51 | 52 | Always call C before any call to the 53 | library. Otherwise the call might fail due to some earlier error. 54 | 55 | =back 56 | 57 | =head2 NOTES FOR RRD CONTRIBUTORS 58 | 59 | Some precautions must be followed when developing RRD from now on: 60 | 61 | =over 62 | 63 | =item * 64 | 65 | Only use thread-safe functions in library code. Many often used libc 66 | functions aren't thread-safe. Take care in the following 67 | situations or when using the following library functions: 68 | 69 | =over 70 | 71 | =item * 72 | 73 | Direct calls to C must be avoided: use C 74 | instead, it provides a per-thread error message. 75 | 76 | =item * 77 | 78 | The C, C, C function families (and some more 79 | C functions) are not thread-safe: use the *C<_r> variants 80 | 81 | =item * 82 | 83 | Time functions: C, C, C, C: use 84 | *C<_r> variants 85 | 86 | =item * 87 | 88 | C: use C 89 | 90 | =item * 91 | 92 | C: use C 93 | 94 | =item * 95 | 96 | Many others (lookup documentation) 97 | 98 | =back 99 | 100 | =item * 101 | 102 | A header file named F is provided 103 | that works with the GNU C-preprocessor to "poison" some of the most 104 | common non-thread-safe functions using the C<#pragma GCC poison> 105 | directive. Just include this header in source files you want to keep 106 | thread-safe. 107 | 108 | =item * 109 | 110 | Do not introduce global variables! 111 | 112 | If you really, really have to use a global variable you may add a new 113 | field to the C structure and modify F, 114 | F and F 115 | 116 | =item * 117 | 118 | Do not use C or C in *C<_r> (neither directly nor 119 | indirectly). 120 | 121 | C uses global variables and behaves badly in a multi-threaded 122 | application when called concurrently. Instead provide a *_r function 123 | taking all options as function parameters. You may provide argc and 124 | **argv arguments for variable length argument lists. See 125 | C as an example. 126 | 127 | =item * 128 | 129 | Do not use the C function! 130 | 131 | It uses lots of global variables. You may use it in functions not designed 132 | to be thread-safe, like in functions wrapping the C<_r> version of some 133 | operation (e.g., C, but not in C) 134 | 135 | =back 136 | 137 | =head2 CURRENTLY IMPLEMENTED THREAD SAFE FUNCTIONS 138 | 139 | Currently there exist thread-safe variants of C, 140 | C, C, C, C, and C. 141 | 142 | =head1 AUTHOR 143 | 144 | Peter Stamfest Epeter@stamfest.atE 145 | -------------------------------------------------------------------------------- /bindings/perl-piped/rrdpl.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="rrd" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 5.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 6 | 7 | CFG=rrd - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "rrdpl.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "rrdpl.mak" CFG="rrd - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "rrd - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") 21 | !MESSAGE "rrd - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP Scc_ProjName "" 26 | # PROP Scc_LocalPath "" 27 | CPP=cl.exe 28 | MTL=midl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "rrd - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "Release" 36 | # PROP BASE Intermediate_Dir "Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "Release" 41 | # PROP Intermediate_Dir "Release" 42 | # PROP Target_Dir "" 43 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 44 | # ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 45 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 46 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 47 | # ADD BASE RSC /l 0x100c /d "NDEBUG" 48 | # ADD RSC /l 0x100c /d "NDEBUG" 49 | BSC32=bscmake.exe 50 | # ADD BASE BSC32 /nologo 51 | # ADD BSC32 /nologo 52 | LINK32=link.exe 53 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 54 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 55 | 56 | !ELSEIF "$(CFG)" == "rrd - Win32 Debug" 57 | 58 | # PROP BASE Use_MFC 0 59 | # PROP BASE Use_Debug_Libraries 1 60 | # PROP BASE Output_Dir "Debug" 61 | # PROP BASE Intermediate_Dir "Debug" 62 | # PROP BASE Target_Dir "" 63 | # PROP Use_MFC 0 64 | # PROP Use_Debug_Libraries 1 65 | # PROP Output_Dir "C:\perl\lib\site\auto\RRD\" 66 | # PROP Intermediate_Dir "Debug" 67 | # PROP Ignore_Export_Lib 0 68 | # PROP Target_Dir "" 69 | # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c 70 | # ADD CPP /W3 /I "C:\perl\lib\CORE" /D "WIN32" /D VERSION=\"0.02\" /D XS_VERSION=\"0.02\" /D "_DEBUG" /D "_CONSOLE" /FR -I../src/ -I../gd1.2 RRD.c /c 71 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 72 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 73 | # ADD BASE RSC /l 0x100c /d "_DEBUG" 74 | # ADD RSC /l 0x100c /d "_DEBUG" 75 | BSC32=bscmake.exe 76 | # ADD BASE BSC32 /nologo 77 | # ADD BSC32 /nologo 78 | LINK32=link.exe 79 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept 80 | # ADD LINK32 c:\perl\lib\core\perl.lib ..\src\debug\rrd.lib ..\gd1.2\debug\gd.lib /dll /incremental:no /debug /machine:IX86 /out:"C:\perl\lib\site\auto\RRD\rrd.dll" 81 | # SUBTRACT LINK32 /pdb:none 82 | 83 | !ENDIF 84 | 85 | # Begin Target 86 | 87 | # Name "rrd - Win32 Release" 88 | # Name "rrd - Win32 Debug" 89 | # Begin Source File 90 | 91 | SOURCE=.\RRD.c 92 | # End Source File 93 | # Begin Source File 94 | 95 | SOURCE=.\RRD.xs 96 | 97 | !IF "$(CFG)" == "rrd - Win32 Release" 98 | 99 | !ELSEIF "$(CFG)" == "rrd - Win32 Debug" 100 | 101 | # Begin Custom Build 102 | InputPath=.\RRD.xs 103 | 104 | "rrd.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" 105 | C:\Perl\bin\perl -Ic:\perl\lib -Ic:\perl\lib C:\perl\lib\ExtUtils/xsubpp\ 106 | -typemap C:\perl\lib\ExtUtils\typemap RRD.xs >RRD.tc && C:\Perl\bin\perl\ 107 | -Ic:\perl\lib -Ic:\perl\lib -MExtUtils::Command -e mv RRD.tc RRD.c 108 | 109 | # End Custom Build 110 | 111 | !ENDIF 112 | 113 | # End Source File 114 | # End Target 115 | # End Project 116 | -------------------------------------------------------------------------------- /src/rrd_hw_math.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * rrd_hw_math.c Math functions for Holt-Winters computations 3 | *****************************************************************************/ 4 | 5 | #include "rrd_tool.h" 6 | #include "rrd_hw_math.h" 7 | 8 | /***************************************************************************** 9 | * RRDtool supports both the additive and multiplicative Holt-Winters methods. 10 | * The additive method makes predictions by adding seasonality to the baseline, 11 | * whereas the multiplicative method multiplies the seasonality coefficient by 12 | * the baseline to make a prediction. This file contains all the differences 13 | * between the additive and multiplicative methods, as well as a few math 14 | * functions common to them both. 15 | ****************************************************************************/ 16 | 17 | /***************************************************************************** 18 | * Functions for additive Holt-Winters 19 | *****************************************************************************/ 20 | 21 | rrd_value_t hw_additive_calculate_prediction( 22 | rrd_value_t intercept, 23 | rrd_value_t slope, 24 | int null_count, 25 | rrd_value_t seasonal_coef) 26 | { 27 | return intercept + slope * null_count + seasonal_coef; 28 | } 29 | 30 | rrd_value_t hw_additive_calculate_intercept( 31 | rrd_value_t hw_alpha, 32 | rrd_value_t observed, 33 | rrd_value_t seasonal_coef, 34 | unival *coefs) 35 | { 36 | return hw_alpha * (observed - seasonal_coef) 37 | + (1 - hw_alpha) * (coefs[CDP_hw_intercept].u_val 38 | + 39 | (coefs[CDP_hw_slope].u_val) * 40 | (coefs[CDP_null_count].u_cnt)); 41 | } 42 | 43 | rrd_value_t hw_additive_calculate_seasonality( 44 | rrd_value_t hw_gamma, 45 | rrd_value_t observed, 46 | rrd_value_t intercept, 47 | rrd_value_t seasonal_coef) 48 | { 49 | return hw_gamma * (observed - intercept) 50 | + (1 - hw_gamma) * seasonal_coef; 51 | } 52 | 53 | rrd_value_t hw_additive_init_seasonality( 54 | rrd_value_t seasonal_coef, 55 | rrd_value_t intercept) 56 | { 57 | return seasonal_coef - intercept; 58 | } 59 | 60 | /***************************************************************************** 61 | * Functions for multiplicative Holt-Winters 62 | *****************************************************************************/ 63 | 64 | rrd_value_t hw_multiplicative_calculate_prediction( 65 | rrd_value_t intercept, 66 | rrd_value_t slope, 67 | int null_count, 68 | rrd_value_t seasonal_coef) 69 | { 70 | return (intercept + slope * null_count) * seasonal_coef; 71 | } 72 | 73 | rrd_value_t hw_multiplicative_calculate_intercept( 74 | rrd_value_t hw_alpha, 75 | rrd_value_t observed, 76 | rrd_value_t seasonal_coef, 77 | unival *coefs) 78 | { 79 | if (seasonal_coef <= 0) { 80 | return DNAN; 81 | } 82 | 83 | return hw_alpha * (observed / seasonal_coef) 84 | + (1 - hw_alpha) * (coefs[CDP_hw_intercept].u_val 85 | + 86 | (coefs[CDP_hw_slope].u_val) * 87 | (coefs[CDP_null_count].u_cnt)); 88 | } 89 | 90 | rrd_value_t hw_multiplicative_calculate_seasonality( 91 | rrd_value_t hw_gamma, 92 | rrd_value_t observed, 93 | rrd_value_t intercept, 94 | rrd_value_t seasonal_coef) 95 | { 96 | if (intercept <= 0) { 97 | return DNAN; 98 | } 99 | 100 | return hw_gamma * (observed / intercept) 101 | + (1 - hw_gamma) * seasonal_coef; 102 | } 103 | 104 | rrd_value_t hw_multiplicative_init_seasonality( 105 | rrd_value_t seasonal_coef, 106 | rrd_value_t intercept) 107 | { 108 | if (intercept <= 0) { 109 | return DNAN; 110 | } 111 | 112 | return seasonal_coef / intercept; 113 | } 114 | 115 | /***************************************************************************** 116 | * Math functions common to additive and multiplicative Holt-Winters 117 | *****************************************************************************/ 118 | 119 | rrd_value_t hw_calculate_slope( 120 | rrd_value_t hw_beta, 121 | unival *coefs) 122 | { 123 | return hw_beta * (coefs[CDP_hw_intercept].u_val - 124 | coefs[CDP_hw_last_intercept].u_val) 125 | + (1 - hw_beta) * coefs[CDP_hw_slope].u_val; 126 | } 127 | 128 | rrd_value_t hw_calculate_seasonal_deviation( 129 | rrd_value_t hw_gamma, 130 | rrd_value_t prediction, 131 | rrd_value_t observed, 132 | rrd_value_t last) 133 | { 134 | return hw_gamma * fabs(prediction - observed) 135 | + (1 - hw_gamma) * last; 136 | } 137 | 138 | rrd_value_t hw_init_seasonal_deviation( 139 | rrd_value_t prediction, 140 | rrd_value_t observed) 141 | { 142 | return fabs(prediction - observed); 143 | } 144 | -------------------------------------------------------------------------------- /src/rrd_thread_safe_nt.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * RRDtool 1.4.3 Copyright by Tobi Oetiker, 1997-2010 3 | * This file: Copyright 2003 Peter Stamfest 4 | * & Tobias Oetiker 5 | * Distributed under the GPL 6 | ***************************************************************************** 7 | * rrd_thread_safe.c Contains routines used when thread safety is required 8 | * for win32 9 | ***************************************************************************** 10 | * $Id$ 11 | *************************************************************************** */ 12 | 13 | #include 14 | #include 15 | /* #include */ 16 | #include "rrd.h" 17 | #include "rrd_tool.h" 18 | 19 | /* Key for the thread-specific rrd_context */ 20 | static DWORD context_key; 21 | static CRITICAL_SECTION CriticalSection; 22 | 23 | 24 | /* Once-only initialisation of the key */ 25 | static DWORD context_key_once = 0; 26 | 27 | 28 | /* Free the thread-specific rrd_context - we might actually use 29 | rrd_free_context instead... 30 | */ 31 | static void context_destroy_context( 32 | void) 33 | { 34 | DeleteCriticalSection(&CriticalSection); 35 | TlsFree(context_key); 36 | context_key_once = 0; 37 | } 38 | static void context_init_context( 39 | void) 40 | { 41 | if (!InterlockedExchange((LONG*)(&context_key_once), 1)) { 42 | context_key = TlsAlloc(); 43 | InitializeCriticalSection(&CriticalSection); 44 | atexit(context_destroy_context); 45 | } 46 | } 47 | rrd_context_t *rrd_get_context( 48 | void) 49 | { 50 | rrd_context_t *ctx; 51 | 52 | context_init_context(); 53 | 54 | ctx = (rrd_context_t*)TlsGetValue(context_key); 55 | if (!ctx) { 56 | ctx = rrd_new_context(); 57 | TlsSetValue(context_key, ctx); 58 | } 59 | return ctx; 60 | } 61 | 62 | 63 | /* this was added by the win32 porters Christof.Wegmann@exitgames.com */ 64 | 65 | rrd_context_t *rrd_force_new_context( 66 | void) 67 | { 68 | rrd_context_t *ctx; 69 | 70 | context_init_context(); 71 | 72 | ctx = rrd_new_context(); 73 | TlsSetValue(context_key, ctx); 74 | 75 | return ctx; 76 | } 77 | 78 | 79 | #undef strerror 80 | const char *rrd_strerror( 81 | int err) 82 | { 83 | rrd_context_t *ctx; 84 | 85 | context_init_context(); 86 | 87 | ctx = rrd_get_context(); 88 | 89 | EnterCriticalSection(&CriticalSection); 90 | strncpy(ctx->lib_errstr, strerror(err), sizeof(ctx->lib_errstr)); 91 | ctx->lib_errstr[sizeof(ctx->lib_errstr) - 1] = '\0'; 92 | LeaveCriticalSection(&CriticalSection); 93 | 94 | return ctx->lib_errstr; 95 | } 96 | 97 | /* 98 | * there much be a re-entrant version of these somewhere in win32 land 99 | */ 100 | struct tm *localtime_r( 101 | const time_t *timep, 102 | struct tm *result) 103 | { 104 | struct tm *local; 105 | 106 | context_init_context(); 107 | 108 | EnterCriticalSection(&CriticalSection); 109 | local = localtime(timep); 110 | memcpy(result, local, sizeof(struct tm)); 111 | LeaveCriticalSection(&CriticalSection); 112 | return result; 113 | } 114 | 115 | char *ctime_r( 116 | const time_t *timep, 117 | char *result) 118 | { 119 | char *local; 120 | 121 | context_init_context(); 122 | 123 | EnterCriticalSection(&CriticalSection); 124 | local = ctime(timep); 125 | strcpy(result, local); 126 | LeaveCriticalSection(&CriticalSection); 127 | return result; 128 | } 129 | 130 | struct tm *gmtime_r( 131 | const time_t *timep, 132 | struct tm *result) 133 | { 134 | struct tm *local; 135 | 136 | context_init_context(); 137 | 138 | EnterCriticalSection(&CriticalSection); 139 | local = gmtime(timep); 140 | memcpy(result, local, sizeof(struct tm)); 141 | LeaveCriticalSection(&CriticalSection); 142 | return result; 143 | } 144 | 145 | /* implementation from Apache's APR library */ 146 | char *strtok_r( 147 | char *str, 148 | const char *sep, 149 | char **last) 150 | { 151 | char *token; 152 | 153 | context_init_context(); 154 | 155 | 156 | if (!str) /* subsequent call */ 157 | str = *last; /* start where we left off */ 158 | 159 | /* skip characters in sep (will terminate at '\0') */ 160 | while (*str && strchr(sep, *str)) 161 | ++str; 162 | 163 | if (!*str) /* no more tokens */ 164 | return NULL; 165 | 166 | token = str; 167 | 168 | /* skip valid token characters to terminate token and 169 | * prepare for the next call (will terminate at '\0) 170 | */ 171 | *last = token + 1; 172 | while (**last && !strchr(sep, **last)) 173 | ++ * last; 174 | 175 | if (**last) { 176 | **last = '\0'; 177 | ++*last; 178 | } 179 | 180 | return token; 181 | } 182 | -------------------------------------------------------------------------------- /bindings/perl-shared/RRDs.pm: -------------------------------------------------------------------------------- 1 | package RRDs; 2 | 3 | use strict; 4 | use vars qw(@ISA $VERSION); 5 | 6 | @ISA = qw(DynaLoader); 7 | 8 | require DynaLoader; 9 | 10 | $VERSION=1.4003; 11 | 12 | bootstrap RRDs $VERSION; 13 | 14 | 1; 15 | __END__ 16 | 17 | =head1 NAME 18 | 19 | RRDs - Access RRDtool as a shared module 20 | 21 | =head1 SYNOPSIS 22 | 23 | use RRDs; 24 | RRDs::error 25 | RRDs::last ... 26 | RRDs::info ... 27 | RRDs::create ... 28 | RRDs::update ... 29 | RRDs::updatev ... 30 | RRDs::graph ... 31 | RRDs::fetch ... 32 | RRDs::tune ... 33 | RRDs::times(start, end) 34 | RRDs::dump ... 35 | RRDs::restore ... 36 | RRDs::flushcached ... 37 | $RRDs::VERSION 38 | 39 | =head1 DESCRIPTION 40 | 41 | =head2 Calling Sequence 42 | 43 | This module accesses RRDtool functionality directly from within Perl. The 44 | arguments to the functions listed in the SYNOPSIS are explained in the regular 45 | RRDtool documentation. The command line call 46 | 47 | rrdtool update mydemo.rrd --template in:out N:12:13 48 | 49 | gets turned into 50 | 51 | RRDs::update ("mydemo.rrd", "--template", "in:out", "N:12:13"); 52 | 53 | Note that 54 | 55 | --template=in:out 56 | 57 | is also valid. 58 | 59 | The RRDs::times function takes two parameters: a "start" and "end" time. 60 | These should be specified in the B format 61 | used by RRDtool. See the B documentation for a detailed 62 | explanation on how to specify time. 63 | 64 | =head2 Error Handling 65 | 66 | The RRD functions will not abort your program even when they can not make 67 | sense out of the arguments you fed them. 68 | 69 | The function RRDs::error should be called to get the error status 70 | after each function call. If RRDs::error does not return anything 71 | then the previous function has completed its task successfully. 72 | 73 | use RRDs; 74 | RRDs::update ("mydemo.rrd","N:12:13"); 75 | my $ERR=RRDs::error; 76 | die "ERROR while updating mydemo.rrd: $ERR\n" if $ERR; 77 | 78 | =head2 Return Values 79 | 80 | The functions RRDs::last, RRDs::graph, RRDs::info, RRDs::fetch and RRDs::times 81 | return their findings. 82 | 83 | B returns a single INTEGER representing the last update time. 84 | 85 | $lastupdate = RRDs::last ... 86 | 87 | B returns an ARRAY containing the x-size and y-size of the 88 | created image and a pointer to an array with the results of the PRINT arguments. 89 | 90 | ($result_arr,$xsize,$ysize) = RRDs::graph ... 91 | print "Imagesize: ${xsize}x${ysize}\n"; 92 | print "Averages: ", (join ", ", @$averages); 93 | 94 | B returns a pointer to a hash. The keys of the hash 95 | represent the property names of the RRD and the values of the hash are 96 | the values of the properties. 97 | 98 | $hash = RRDs::info "example.rrd"; 99 | foreach my $key (keys %$hash){ 100 | print "$key = $$hash{$key}\n"; 101 | } 102 | 103 | B takes the same parameters as B but it returns a 104 | pointer to hash. The hash returned contains meta information about the 105 | graph. Like its size as well as the position of the graph area on the image. 106 | When calling with and empty filename than the contents of the graph will be 107 | returned in the hash as well (key 'image'). 108 | 109 | B also returns a pointer to hash. The keys of the hash 110 | are concatenated strings of a timestamp, RRA index, and data source name for 111 | each consolidated data point (CDP) written to disk as a result of the 112 | current update call. The hash values are CDP values. 113 | 114 | B is the most complex of 115 | the pack regarding return values. There are 4 values. Two normal 116 | integers, a pointer to an array and a pointer to a array of pointers. 117 | 118 | my ($start,$step,$names,$data) = RRDs::fetch ... 119 | print "Start: ", scalar localtime($start), " ($start)\n"; 120 | print "Step size: $step seconds\n"; 121 | print "DS names: ", join (", ", @$names)."\n"; 122 | print "Data points: ", $#$data + 1, "\n"; 123 | print "Data:\n"; 124 | for my $line (@$data) { 125 | print " ", scalar localtime($start), " ($start) "; 126 | $start += $step; 127 | for my $val (@$line) { 128 | printf "%12.1f ", $val; 129 | } 130 | print "\n"; 131 | } 132 | 133 | B returns two integers which are the number of seconds since 134 | epoch (1970-01-01) for the supplied "start" and "end" arguments, respectively. 135 | 136 | See the examples directory for more ways to use this extension. 137 | 138 | =head1 NOTE 139 | 140 | If you are manipulating the TZ variable you should also call the POSIX 141 | function L to initialize all internal state of the library for properly 142 | operating in the timezone of your choice. 143 | 144 | use POSIX qw(tzset); 145 | $ENV{TZ} = 'CET'; 146 | POSIX::tzset(); 147 | 148 | 149 | =head1 AUTHOR 150 | 151 | Tobias Oetiker Etobi@oetiker.chE 152 | 153 | =cut 154 | -------------------------------------------------------------------------------- /examples/piped-demo.pl.in: -------------------------------------------------------------------------------- 1 | #! @PERL@ 2 | 3 | use lib qw( @prefix@/lib/perl ); 4 | 5 | use RRDp; 6 | 7 | # this simpulates a standard mrtg-2.x setup ... we can use this to 8 | # compare performance ... 9 | 10 | $main::DEBUG=0; 11 | $STEP = 300; 12 | $RUNS = 12*24*30*6; 13 | $GRUNS = 20; 14 | $RRD = "piped-demo.rrd"; 15 | $SVG = "piped-demo.svg"; 16 | $PNG = "piped-demo.png"; 17 | 18 | # some magic to find the correct rrdtol executable 19 | $prefix="@prefix@"; 20 | 21 | if ( -x "@exec_prefix@/bin/rrdtool") { 22 | RRDp::start "@exec_prefix@/bin/rrdtool"; 23 | } elsif ( -x "../../../bin/rrdtool") { 24 | RRDp::start "../../../bin/rrdtool"; 25 | } else { 26 | RRDp::start "../src/rrdtool"; 27 | } 28 | 29 | print "* Creating RRD with properties equivalent to mrtg-2.x logfile\n\n"; 30 | 31 | $START = time()-$RUNS*$STEP; 32 | 33 | RRDp::cmd "create $RRD -b $START -s $STEP 34 | DS:in:GAUGE:400:U:U 35 | DS:out:GAUGE:400:U:U 36 | RRA:AVERAGE:0.5:1:600 37 | RRA:AVERAGE:0.5:6:600 38 | RRA:MAX:0.5:6:600 39 | RRA:AVERAGE:0.5:24:600 40 | RRA:MAX:0.5:24:600 41 | RRA:AVERAGE:0.5:144:600 42 | RRA:MAX:0.5:144:600"; 43 | 44 | $answer = RRDp::read; 45 | ($user,$sys,$real) = ($RRDp::user,$RRDp::sys,$RRDp::real); 46 | 47 | print "* Filling RRD with $RUNS Values. One moment please ...\n"; 48 | print " If you are running over NFS this will take *MUCH* longer\n\n"; 49 | 50 | for ($i=$START+1; 51 | $i<$START+$STEP*$RUNS; 52 | $i+=$STEP+int((rand()-0.5)*7)){ 53 | 54 | $line = "update $RRD $i:".int(rand(100000)).":".int(rand(100000)); 55 | RRDp::cmd $line; 56 | $answer = RRDp::read; 57 | } 58 | 59 | ($user1,$sys1,$real1) = ($RRDp::user,$RRDp::sys,$RRDp::real); 60 | 61 | printf "-- performance analysis Update test\n". 62 | " usr/upd: %1.5fs sys/upd: %1.5fs real/upd: %1.5fs upd/sec: %1.0f\n", 63 | ($user1-$user)/($RUNS), ($sys1-$sys)/($RUNS), 64 | ($real1-$real)/($RUNS), ($RUNS)/($real1-$real); 65 | print "\n"; 66 | # creating some graphs 67 | 68 | print "* Creating $GRUNS SVG graphs: $SVG\n\n"; 69 | $now = time; 70 | $localtime = scalar localtime(time); 71 | $localtime = s/:/\\:/g; 72 | for ($i=0;$i<$GRUNS;$i++) { 73 | RRDp::cmd "graph $SVG ", "--title 'Test GRAPH' ", 74 | "--imgformat SVG --height 150 --vertical-label 'Dummy Units' ". 75 | "--start now".(-$RUNS*$STEP), 76 | "--color ARROW#bfbfbf", 77 | "DEF:alpha=$RRD:in:AVERAGE", 78 | "DEF:beta=$RRD:out:AVERAGE", 79 | "CDEF:calc=alpha,beta,+,1.5,/", 80 | "AREA:alpha#0022e9:Alpha", 81 | "STACK:beta#00b871:Beta", 82 | "STACK:calc#ff0091:Calc\\j", 83 | "PRINT:alpha:AVERAGE:'Average Alpha\\: %1.2lf %S'", 84 | "PRINT:alpha:MIN:'Min Alpha\\: %1.2lf %S'", 85 | "PRINT:alpha:MAX:'Max Alpha\\: %1.2lf %S'", 86 | "GPRINT:calc:AVERAGE:'Average calc\\: %1.2lf %S\\r'", 87 | "GPRINT:calc:MIN:'Min calc\\: %1.2lf %S'", 88 | "GPRINT:calc:MAX:'Max calc\\: %1.2lf %S'", 89 | "VRULE:".($now-3600)."#008877:'60 Minutes ago'", 90 | "COMMENT:'\\s'", 91 | "COMMENT:'Graph created on\\: ".$localtime."\\c'"; 92 | 93 | $answer = RRDp::read; 94 | } 95 | ($user2,$sys2,$real2) = ($RRDp::user,$RRDp::sys,$RRDp::real); 96 | 97 | print "ANSWER:\n$$answer"; 98 | 99 | printf "\n-- average Time for one Graph\n". 100 | " usr/grf: %1.5fs sys/grf: %1.5fs real/grf: %1.5fs graphs/sec: %1.2f\n", 101 | ($user2-$user1)/$GRUNS, 102 | ($sys2-$sys1)/$GRUNS, 103 | ($real2-$real1)/$GRUNS, 104 | $GRUNS/($real2-$real1); 105 | 106 | print "\n\n* Creating $GRUNS PNG graphs: $PNG\n\n"; 107 | 108 | $now = time; 109 | ($user1,$sys1,$real1) = ($RRDp::user,$RRDp::sys,$RRDp::real); 110 | my $local = "".localtime(time()); 111 | $local =~ s/:/\\:/g; 112 | 113 | for ($i=0;$i<$GRUNS;$i++) { 114 | RRDp::cmd "graph $PNG ", "--title 'Test GRAPH' ", 115 | "--imgformat PNG --height 150 --vertical-label 'Dummy Units' ". 116 | "--start now".(-$RUNS*$STEP), 117 | "--color ARROW#bfbfbf", 118 | "DEF:alpha=$RRD:in:AVERAGE", 119 | "DEF:beta=$RRD:out:AVERAGE", 120 | "CDEF:calc=alpha,beta,+,1.5,/", 121 | "AREA:alpha#0022e9:Alpha", 122 | "STACK:beta#00b871:Beta", 123 | "STACK:calc#ff0091:Calc\\j", 124 | "PRINT:alpha:AVERAGE:'Average Alpha\\: %1.2lf %S'", 125 | "PRINT:alpha:MIN:'Min Alpha\\: %1.2lf %S'", 126 | "PRINT:alpha:MAX:'Max Alpha\\: %1.2lf %S'", 127 | "GPRINT:calc:AVERAGE:'Average calc\\: %1.2lf %S\\r'", 128 | "GPRINT:calc:MIN:'Min calc\\: %1.2lf %S'", 129 | "GPRINT:calc:MAX:'Max calc\\: %1.2lf %S'", 130 | "VRULE:".($now-3600)."#008877:'60 Minutes ago'", 131 | "COMMENT:'\\s'", 132 | "COMMENT:'Graph created on\\: $local\\c'"; 133 | 134 | $answer = RRDp::read; 135 | } 136 | ($user2,$sys2,$real2) = ($RRDp::user,$RRDp::sys,$RRDp::real); 137 | 138 | print "ANSWER:\n$$answer"; 139 | 140 | printf "\n-- average Time for one PNG Graph\n". 141 | " usr/grf: %1.5fs sys/grf: %1.5fs real/grf: %1.5fs". 142 | " graphs/sec: %1.2f\n\n", 143 | ($user2-$user1)/$GRUNS, 144 | ($sys2-$sys1)/$GRUNS, 145 | ($real2-$real1)/$GRUNS, 146 | $GRUNS/($real2-$real1); 147 | 148 | RRDp::end; 149 | -------------------------------------------------------------------------------- /src/rrd_format.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * RRDtool 1.4.3 Copyright by Tobi Oetiker, 1997-2010 3 | ***************************************************************************** 4 | * rrd_format.c RRD Database Format helper functions 5 | ***************************************************************************** 6 | * $Id$ 7 | * $Log$ 8 | * Revision 1.5 2004/05/18 18:53:03 oetiker 9 | * big spell checking patch -- slif@bellsouth.net 10 | * 11 | * Revision 1.4 2003/02/13 07:05:27 oetiker 12 | * Find attached the patch I promised to send to you. Please note that there 13 | * are three new source files (src/rrd_is_thread_safe.h, src/rrd_thread_safe.c 14 | * and src/rrd_not_thread_safe.c) and the introduction of librrd_th. This 15 | * library is identical to librrd, but it contains support code for per-thread 16 | * global variables currently used for error information only. This is similar 17 | * to how errno per-thread variables are implemented. librrd_th must be linked 18 | * alongside of libpthred 19 | * 20 | * There is also a new file "THREADS", holding some documentation. 21 | * 22 | * -- Peter Stamfest 23 | * 24 | * Revision 1.3 2002/02/01 20:34:49 oetiker 25 | * fixed version number and date/time 26 | * 27 | * Revision 1.2 2001/03/10 23:54:39 oetiker 28 | * Support for COMPUTE data sources (CDEF data sources). Removes the RPN 29 | * parser and calculator from rrd_graph and puts then in a new file, 30 | * rrd_rpncalc.c. Changes to core files rrd_create and rrd_update. Some 31 | * clean-up of aberrant behavior stuff, including a bug fix. 32 | * Documentation update (rrdcreate.pod, rrdupdate.pod). Change xml format. 33 | * -- Jake Brutlag 34 | * 35 | * Revision 1.1.1.1 2001/02/25 22:25:05 oetiker 36 | * checkin 37 | * 38 | * Revision 1.3 1998/03/08 12:35:11 oetiker 39 | * checkpointing things because the current setup seems to work 40 | * according to the things said in the manpages 41 | * 42 | * Revision 1.2 1998/02/26 22:58:22 oetiker 43 | * fixed define 44 | * 45 | * Revision 1.1 1998/02/21 16:14:41 oetiker 46 | * Initial revision 47 | * 48 | * 49 | *****************************************************************************/ 50 | #include "rrd_tool.h" 51 | 52 | #define converter(VV,VVV) \ 53 | if (strcmp(#VV, string) == 0) return VVV; 54 | 55 | /* conversion functions to allow symbolic entry of enumerations */ 56 | enum dst_en dst_conv( 57 | char *string) 58 | { 59 | converter(COUNTER, DST_COUNTER) 60 | converter(ABSOLUTE, DST_ABSOLUTE) 61 | converter(GAUGE, DST_GAUGE) 62 | converter(DERIVE, DST_DERIVE) 63 | converter(COMPUTE, DST_CDEF) 64 | rrd_set_error("unknown data acquisition function '%s'", string); 65 | return (enum dst_en)(-1); 66 | } 67 | 68 | 69 | enum cf_en cf_conv( 70 | const char *string) 71 | { 72 | 73 | converter(AVERAGE, CF_AVERAGE) 74 | converter(MIN, CF_MINIMUM) 75 | converter(MAX, CF_MAXIMUM) 76 | converter(LAST, CF_LAST) 77 | converter(HWPREDICT, CF_HWPREDICT) 78 | converter(MHWPREDICT, CF_MHWPREDICT) 79 | converter(DEVPREDICT, CF_DEVPREDICT) 80 | converter(SEASONAL, CF_SEASONAL) 81 | converter(DEVSEASONAL, CF_DEVSEASONAL) 82 | converter(FAILURES, CF_FAILURES) 83 | rrd_set_error("unknown consolidation function '%s'", string); 84 | return (enum cf_en)(-1); 85 | } 86 | 87 | const char *cf_to_string (enum cf_en cf) 88 | { 89 | switch (cf) 90 | { 91 | case CF_AVERAGE: return "AVERAGE"; 92 | case CF_MINIMUM: return "MIN"; 93 | case CF_MAXIMUM: return "MAX"; 94 | case CF_LAST: return "LAST"; 95 | case CF_HWPREDICT: return "HWPREDICT"; 96 | case CF_SEASONAL: return "SEASONAL"; 97 | case CF_DEVPREDICT: return "DEVPREDICT"; 98 | case CF_DEVSEASONAL: return "DEVSEASONAL"; 99 | case CF_FAILURES: return "FAILURES"; 100 | case CF_MHWPREDICT: return "MHWPREDICT"; 101 | 102 | default: 103 | return NULL; 104 | } 105 | } /* char *cf_to_string */ 106 | 107 | #undef converter 108 | 109 | long ds_match( 110 | rrd_t *rrd, 111 | char *ds_nam) 112 | { 113 | unsigned long i; 114 | 115 | for (i = 0; i < rrd->stat_head->ds_cnt; i++) 116 | if ((strcmp(ds_nam, rrd->ds_def[i].ds_nam)) == 0) 117 | return i; 118 | rrd_set_error("unknown data source name '%s'", ds_nam); 119 | return -1; 120 | } 121 | 122 | off_t rrd_get_header_size( 123 | rrd_t *rrd) 124 | { 125 | return sizeof(stat_head_t) + \ 126 | sizeof(ds_def_t) * rrd->stat_head->ds_cnt + \ 127 | sizeof(rra_def_t) * rrd->stat_head->rra_cnt + \ 128 | sizeof(time_t) + \ 129 | sizeof(live_head_t) + \ 130 | sizeof(pdp_prep_t) * rrd->stat_head->ds_cnt + \ 131 | sizeof(cdp_prep_t) * rrd->stat_head->ds_cnt * rrd->stat_head->rra_cnt + \ 132 | sizeof(rra_ptr_t) * rrd->stat_head->rra_cnt; 133 | } 134 | -------------------------------------------------------------------------------- /src/hash_32.c: -------------------------------------------------------------------------------- 1 | /* 2 | * hash_32 - 32 bit Fowler/Noll/Vo hash code 3 | * 4 | * 5 | *** 6 | * 7 | * Fowler/Noll/Vo hash 8 | * 9 | * The basis of this hash algorithm was taken from an idea sent 10 | * as reviewer comments to the IEEE POSIX P1003.2 committee by: 11 | * 12 | * Phong Vo (http://www.research.att.com/info/kpv/) 13 | * Glenn Fowler (http://www.research.att.com/~gsf/) 14 | * 15 | * In a subsequent ballot round: 16 | * 17 | * Landon Curt Noll (http://reality.sgi.com/chongo/) 18 | * 19 | * improved on their algorithm. Some people tried this hash 20 | * and found that it worked rather well. In an EMail message 21 | * to Landon, they named it the ``Fowler/Noll/Vo'' or FNV hash. 22 | * 23 | * FNV hashes are architected to be fast while maintaining a low 24 | * collision rate. The FNV speed allows one to quickly hash lots 25 | * of data while maintaining a reasonable collision rate. See: 26 | * 27 | * http://reality.sgi.com/chongo/tech/comp/fnv/ 28 | * 29 | * for more details as well as other forms of the FNV hash. 30 | *** 31 | * 32 | * NOTE: The FNV-0 historic hash is not recommended. One should use 33 | * the FNV-1 hash instead. 34 | * 35 | * To use the 32 bit FNV-0 historic hash, pass FNV0_32_INIT as the 36 | * Fnv32_t hashval argument to fnv_32_buf() or fnv_32_str(). 37 | * 38 | * To use the recommended 32 bit FNV-1 hash, pass FNV1_32_INIT as the 39 | * Fnv32_t hashval argument to fnv_32_buf() or fnv_32_str(). 40 | * 41 | *** 42 | * 43 | * Please do not copyright this code. This code is in the public domain. 44 | * 45 | * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 46 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO 47 | * EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR 48 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 49 | * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 50 | * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 51 | * PERFORMANCE OF THIS SOFTWARE. 52 | * 53 | * By: 54 | * chongo /\oo/\ 55 | * http://reality.sgi.com/chongo/ 56 | * EMail: chongo_fnv at prime dot engr dot sgi dot com 57 | * 58 | * Share and Enjoy! :-) 59 | */ 60 | 61 | #include 62 | #include "fnv.h" 63 | 64 | 65 | /* 66 | * 32 bit magic FNV-0 and FNV-1 prime 67 | */ 68 | #define FNV_32_PRIME ((Fnv32_t)0x01000193) 69 | 70 | 71 | /* 72 | * fnv_32_buf - perform a 32 bit Fowler/Noll/Vo hash on a buffer 73 | * 74 | * input: 75 | * buf - start of buffer to hash 76 | * len - length of buffer in octets 77 | * hval - previous hash value or 0 if first call 78 | * 79 | * returns: 80 | * 32 bit hash as a static hash type 81 | * 82 | * NOTE: To use the 32 bit FNV-0 historic hash, use FNV0_32_INIT as the hval 83 | * argument on the first call to either fnv_32_buf() or fnv_32_str(). 84 | * 85 | * NOTE: To use the recommended 32 bit FNV-1 hash, use FNV1_32_INIT as the hval 86 | * argument on the first call to either fnv_32_buf() or fnv_32_str(). 87 | */ 88 | Fnv32_t fnv_32_buf( 89 | const void *buf, 90 | size_t len, 91 | Fnv32_t hval) 92 | { 93 | const unsigned char *bp = (const unsigned char *) buf; /* start of buffer */ 94 | const unsigned char *be = bp + len; /* beyond end of buffer */ 95 | 96 | /* 97 | * FNV-1 hash each octet in the buffer 98 | */ 99 | while (bp < be) { 100 | 101 | /* multiply by the 32 bit FNV magic prime mod 2^64 */ 102 | hval *= FNV_32_PRIME; 103 | 104 | /* xor the bottom with the current octet */ 105 | hval ^= (Fnv32_t) *bp++; 106 | } 107 | 108 | /* return our new hash value */ 109 | return hval; 110 | } 111 | 112 | 113 | /* 114 | * fnv_32_str - perform a 32 bit Fowler/Noll/Vo hash on a string 115 | * 116 | * input: 117 | * str - string to hash 118 | * hval - previous hash value or 0 if first call 119 | * 120 | * returns: 121 | * 32 bit hash as a static hash type 122 | * 123 | * NOTE: To use the 32 bit FNV-0 historic hash, use FNV0_32_INIT as the hval 124 | * argument on the first call to either fnv_32_buf() or fnv_32_str(). 125 | * 126 | * NOTE: To use the recommended 32 bit FNV-1 hash, use FNV1_32_INIT as the hval 127 | * argument on the first call to either fnv_32_buf() or fnv_32_str(). 128 | */ 129 | Fnv32_t fnv_32_str( 130 | const char *str, 131 | Fnv32_t hval) 132 | { 133 | const unsigned char *s = (const unsigned char *) str; /* unsigned string */ 134 | 135 | /* 136 | * FNV-1 hash each octet in the buffer 137 | */ 138 | while (*s) { 139 | 140 | /* multiply by the 32 bit FNV magic prime mod 2^64 */ 141 | hval *= FNV_32_PRIME; 142 | 143 | /* xor the bottom with the current octet */ 144 | hval ^= (Fnv32_t) *s++; 145 | } 146 | 147 | /* return our new hash value */ 148 | return hval; 149 | } 150 | 151 | /* a wrapper function for fnv_32_str */ 152 | unsigned long FnvHash( 153 | const char *str) 154 | { 155 | return fnv_32_str(str, FNV1_32_INIT); 156 | } 157 | --------------------------------------------------------------------------------