# RRDtool Cache Daemon

In large installations sooner or later one will recognize that processing the performance data will result in a relatively high I/O load. RRDtool has to do very much disk updates but cannot use the disk cache in an optimal way.

One improvement is made by collecting and sorting the data. It is more effective to write many updates to an RRD database in one block. The disk cache can be used more effectively that way.

The current RRDtool ( SVN trunk 1550+ ) contains rrdcached which should improve exactly this situation.

At this point I'd like to thank Florian octo Forster, Kevin Brintnall and Tobi Oetiker. The development of this daemon has been coordinated exemplary on the rrd-developers mailing list.

## Mode of operation

The rrdcached is working as a daemon in the background and opens a UNIX or TCP socket to wait for requests of rrdtool. Due to security reasons newer versions of rrdcached cannot use absolute paths for network access anymore so the only possible way are unix sockets.

### rrdcached

rrdcached recognizes some important options which are passed during startup.

Option -l defines the socket the daemon will listen for update requests. The default TCP port will be 42217.

    -l unix:/path/to/rrdcached.sock
    -l /path/to/rrdcached.sock
    -l 127.0.0.1
    -l 127.0.0.1:8888

Option -P specifies which commands are usable with the RRD data bases

    -P FLUSH,PENDING

Option -s allows to change the group ownership of the unix socket

    -s nagios

Option -m sets the permissions of the unix socket in the usual octal format

    -m 0660

Option -w specifies the interval (in seconds) the data will be written to disk.

    -w 1800

Option -z defines a maximum delay which will be used to spread the write cycles over a certain range [0-delay] to avoid parallel write accesses. The value of option -z must not be larger than -w.

    -z 1800

Option -p defines a PID file

    -p /var/run/rrdcached.pid

Option -j defines the path to a journaling directory. All requests will be logged there so that they can be processed after a restart in case the daemon crashes.

    -j /var/cache/rrdcached

These options may result in a call of rrdcached with the following parameters

     rrdcached -w 1800 -z 1800 -p /tmp/rrdcached.pid -j /tmp  -s nagios -m 0660 -l unix:/tmp/rrdcached.sock

### rrdtool

RRDtool itself will be informed about the daemon using the option –daemon=<socket>.

     rrdtool --daemon=unix:/tmp/rrdcached.sock update ...

Of course this has to correspond with the options of rrdcached!

## Integration into PNP

Because two components of PNP have to prepared for the use of rrdcached there are changes in two config files.

1. Adjustment of process_perfdata.cfg for the data collector process_perfdata.pl

    # EXPERIMENTAL rrdcached Support
    # Use only with rrdtool svn revision 1511+
    #
    RRD_DAEMON_OPTS = unix:/var/run/rrdcached.sock

2. Adjustment of config_local.php (or config.php) for the web interface

    #
    # EXPERIMENTAL rrdcached Support
    # Use only with rrdtool svn revision 1511+
    #
    # $conf['RRD_DAEMON_OPTS'] = 'unix:/tmp/rrdcached.sock';
    $conf['RRD_DAEMON_OPTS'] = 'unix:/var/run/rrdcached.sock';

The sample files contain the relevant options.

back to contents | migrating RRD files