Installing RRDTool for PHP on Ubuntu Server

November 11, 2009
RRD tool

rrdtool is a data logging and graphing utility that's great for system monitoring.

Compiling the latest RRDTool

cd ~
wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.1.tar.gz
tar xzvf rrdtool-1.4.1.tar.gz
cd rrdtool-1.4.1
INSTALL_DIR=/opt/rrdtool-1.4.1
sudo mkdir $INSTALL_DIR
sudo chmod 777 $INSTALL_DIR
./configure --prefix=$INSTALL_DIR && make && make install
cd $INSTALL_DIR
sudo cp -r * /usr
rm -r ~/rrdtool-1.4.1
If you want to bypass the steps above and use a possibly-older version of RRD tool, just run:
sudo apt-get install librrd2-dev rrdtool

PHP Extension

Download and install the PHP extension source:
cd ~
wget http://oss.oetiker.ch/rrdtool/pub/contrib/php_rrdtool.tar.gz
tar zxvf php_rrdtool.tar.gz
sudo mv ./rrdtool /usr/include/php5/ext/rrdtool
Configure and build the extension:
cd /usr/include/php5/ext/rrdtool
sudo phpize
sudo ./configure --with-php-config=/usr/bin/php-config --with-rrdtool=/usr
sudo make
sudo make install
sudo nano /etc/php5/conf.d/rrdtool.ini
Write the contents below to the "rrdtool.ini" configuration file. Note: the file won't already exist—you're creating it now:
; Enable rrdtool extension module
extension=rrdtool.so
Save the file, restart Apache, and she should be all good to go!
sudo service apache2 restart

The Result

To see if the install went fine, create a little *.php file that prints out the php configuration: <?php phpinfo(); ?>. When you pull up the script in your browser, you should see a section labeled "rrdtool" if the install went a-okay.

Where to go from here...

Follow me on Twitter

Tags: , , ,

The Commentary

  1. Gravatar

    dude, this looks so fresh and pretty


  2. Gravatar

    Hi,

    The extension build fine, but when i tried to use the function rrd_create, i got the following error :

    Create error: can’t parse argument ‘net.rrd’

    The code used was :
    $fname = “net.rrd”;
    $ret = rrd_create($fname, $opts, count($opts));

    If anyone has an idea… seems there’s something weird in the API… Something related to my versions ? RRDtool 1.3.1 and PHP 5.2.5, and i’m on a 64-bits (AMD) plateform.

    Thanks for any help,
    regards,