Cacti Pi – How To Install Cacti Spine on Raspberry Pi


In this post we will continue optimizing Cacti with How to install Cacti Spine on Raspberry Pi.

As per Cacti.net:
“Spine, formerly Cactid, is a poller for Cacti that primarily strives to be as fast as possible. For this reason it is written in native C, makes use of POSIX threads, and is linked directly against the net-snmp library for minimal SNMP polling overhead.”

Generally, Spine is used in large Cacti installs, where many devices need to be polled in under 300 seconds. When you expand the amount of devices you are monitoring the polling cycle gets longer and when using php.cmd it can get close to the 300 second window quite fast. Enter Spine.

In our case although I am monitoring a small network, we want to make sure the polling is completed as quickly as possible to ensure we return our precious CPU back to the Raspberry Pi for other processes.

The following instructions assume you followed my Cacti Pi install, please ensure if you used different directories or credentials you insert them accordingly.

root@raspberrypi:~#apt-get update
root@raspberrypi:~#apt-get install autoconf automake libtool
root@raspberrypi:~#apt-get install libsnmp-dev libsnmp-base libsnmp15
root@raspberrypi:~#apt-get install libmysqlclient-dev

root@raspberrypi:~#cd /var/www/cacti

root@raspberrypi:/var/www/cacti#wget http://www.cacti.net/downloads/spine/cacti-spine-0.8.8a.tar.gz

root@raspberrypi:/var/www/cacti#tar -xzvf cacti-spine-0.8.8a.tar.gz
root@raspberrypi:/var/www/cacti#mv cacti-spine-0.8.8a spine
root@raspberrypi:/var/www/cacti#cd spine

root@raspberrypi:#aclocal
root@raspberrypi:#libtoolize --force
root@raspberrypi:#autoheader
root@raspberrypi:#autoconf
root@raspberrypi:#automake
root@raspberrypi:#./configure
root@raspberrypi:#make
root@raspberrypi:#make install

root@raspberrypi:#cd /usr/local/spine/etc/
root@raspberrypi:#cp spine.conf.dist spine.conf
root@raspberrypi:#vi spine.conf

Change from:
(settings based on Cacti Pi install tutorial, your settings may differ)

DB_Host localhost
DB_Database cacti
DB_User cactiuser
DB_Pass cactiuser
DB_Port 3306

To:

DB_Host localhost
DB_Database cacti
DB_User cactiuser
DB_Pass cacti
DB_Port 3306

Load your Cacti web interface and update Alternate Poller Path:

Console > Settings >Paths >Alternate Poller Path >

Spine Poller File Path = /usr/local/spine/bin/spine

Update Cacti to use Spine rather than cmd.php

Console > Settings >Poller

Poller Type = spine

 

And Spine is live.

You can monitor the poll time under System Utilities > View Cacti Log File where you should see an improvement compared to cmd.php.

Here’s the benefit I have seen thus far:

cmd.php

08/29/2012 11:35:15 PM – SYSTEM STATS: Time:12.4591 Method:cmd.php Processes:3 Threads:N/A Hosts:4 HostsPerProcess:2 DataSources:26 RRDsProcessed:14
08/29/2012 11:30:22 PM – SYSTEM STATS: Time:17.4255 Method:cmd.php Processes:3 Threads:N/A Hosts:4 HostsPerProcess:2 DataSources:26 RRDsProcessed:14
08/29/2012 11:26:06 PM – SYSTEM STATS: Time:37.7926 Method:cmd.php Processes:3 Threads:N/A Hosts:4 HostsPerProcess:2 DataSources:26 RRDsProcessed:14
08/29/2012 11:21:12 PM – SYSTEM STATS: Time:36.7945 Method:cmd.php Processes:3 Threads:N/A Hosts:4 HostsPerProcess:2 DataSources:26 RRDsProcessed:14

Spine

08/30/2012 12:30:13 AM – SYSTEM STATS: Time:10.5919 Method:spine Processes:3 Threads:1 Hosts:4 HostsPerProcess:2 DataSources:26 RRDsProcessed:14
08/30/2012 12:25:14 AM – SYSTEM STATS: Time:10.5819 Method:spine Processes:3 Threads:1 Hosts:4 HostsPerProcess:2 DataSources:26 RRDsProcessed:14
08/30/2012 12:20:14 AM – SYSTEM STATS: Time:10.4223 Method:spine Processes:3 Threads:1 Hosts:4 HostsPerProcess:2 DataSources:26 RRDsProcessed:14
08/30/2012 12:15:14 AM – SYSTEM STATS: Time:10.5870 Method:spine Processes:3 Threads:1 Hosts:4 HostsPerProcess:2 DataSources:26 RRDsProcessed:14

 

As you can see Spine has brought average poller time down to a steady 10 seconds. You will see even more benefit when adding more devices and data sources.

 

 

 

13 thoughts on “Cacti Pi – How To Install Cacti Spine on Raspberry Pi”

  1. Hi, Thanks again for a wonderful guide!
    But I ran into some issues… Not sure if I made a mistake somewhere along the install or that what happened.
    Followed the guide as above and everything went fine until I switched over to spine instead of cmd.php. Below is 2 lines of the log.

    10/12/2012 02:05:04 PM – SYSTEM STATS: Time:298.8262 Method:spine Processes:1 Threads:1 Hosts:7 HostsPerProcess:7 DataSources:85 RRDsProcessed:0
    10/12/2012 02:00:04 PM – SYSTEM STATS: Time:298.9659 Method:spine Processes:1 Threads:1 Hosts:7 HostsPerProcess:7 DataSources:85 RRDsProcessed:0

    10/12/2012 01:45:24 PM – SYSTEM STATS: Time:20.5001 Method:cmd.php Processes:1 Threads:N/A Hosts:7 HostsPerProcess:7 DataSources:85 RRDsProcessed:50

    As you can see above when I switched over to spine the time it took shot up to 300~ and the RRDsProcessed droped to 0, thus no nothing to graph with.
    Did I miss something obvious somewhere, like a setting that I should have ticked? Any advice would be awesome!

    1. After loads of googling and mroe googling, it seems that permissions wat needed on a few files…. So finally got it working.

      10/12/2012 09:25:13 PM – SYSTEM STATS: Time:10.8473 Method:spine Processes:1 Threads:1 Hosts:7 HostsPerProcess:7 DataSources:85 RRDsProcessed:49

      Down to ~10ms odd from a normal 60+! Huge improvement!
      Thanks again for making this guide!

      1. Hey Pieter,

        It was my mistake, had an error in the SQL db settings. Updated the db name to ‘cacti’ instead of ‘cactidb’

        Glad you solved it, sorry for the delay in response!

  2. Thanks again for preparing this – awesome help! Just wondering if the config file entry “DB_Database cactidb” is the same? I checked the mysql config, and I think the db name is cacti?

  3. I think you have a mistake where you suggest to change the DB_Database in the spine.conf to cactidb. In the initial tutorial for setting up cacti on the RPI, we created a DB named cacti, not cactidb, so the correct line is “DB_Database cacti”. I first tried it with cactidb and the poller kept using the CPU forever and the graphs showed nothing. Then I changed to cacti and now everything is fine 🙂 Thank you for the amazing tutorials about setting up cacti on the Raspberry Pi!

    1. Good Eye Bazso!

      Updated to the correct db settings according to the Cacti Pi tutorial! Sorry for the inconvenience guys!

  4. i was able to do everything up to this step:

    root@raspberrypi:#cd /usr/local/spine/etc/
    root@raspberrypi:#cp spine.conf.dist spine.conf
    root@raspberrypi:#vi spine.conf

    There is no spine directory inside of /usr/local.
    When did this get created? i followed your cacti pi install and this never got created in those steps.

    The only spine folder is under /var/www/cacti/spine

    Any ideas what I did wrong?

    Great blog!

    1. nevermind i figured it out. The issue was that I was not giving the ‘sudo’ command when I issued the command ‘make’ because I was not the root user.

    2. You likely did nothing wrong! It all depends on how you installed Spine. Different install methods will plop things in different directories…as long as you found the conf file you should be all good!!

Leave a Reply

Your email address will not be published. Required fields are marked *