How to install Cacti and Spine ver. 1.2.x on Ubuntu 20.04

If you figure out how to do something interesting/cool in Cacti and want to share it with the community, please post your experience here.

Moderators: Developers, Moderators

Post Reply
ruehlb
Posts: 2
Joined: Tue Feb 07, 2017 12:25 pm

How to install Cacti and Spine ver. 1.2.x on Ubuntu 20.04

Post by ruehlb »

**Edit: updated to install latest version available since the 1.1.x versions are frequently being updated.
**Edit2: Added upgrade procedure at the bottom.
**Edit3: This thread has been hanging in there so I am updating it for Ubuntu LTS 20.04

With the release of 1.0 and it not existing the the Ubuntu repo's, I found no directions that helped with the install. During several failed attempts, I finally found the right match of dependencies and libraries needed to install both Cacti and Spine versions 1.0. and up.

Items in blue can be modified to the installers preference.
Most all of these commands require root permissions and were written to be preformed by a root user. You can elevate the local users permissions by running sudo -s if permitted. Use caution when running commands with root privileges.

Installing Cacti

1. Install dependencies
apt install -y apache2 php libapache2-mod-php php-mysql php-snmp php-xml php-ldap php-mbstring php-gmp snmp php-gd rrdtool mysql-server libssl-dev libphp-phpmailer dos2unix autotools-dev autoconf
2. Create a new user for cacti
useradd cactiuser
3. Add the timezone tables to the MySQL database
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql
4. Access the MySQL interface
mysql -u root -p
5. Create the cacti database, user, and set permissions.
create database cactidb;
CREATE USER 'cactiuser'@'localhost' IDENTIFIED BY '<password>';
GRANT ALL ON cactidb.* TO 'cactiuser'@'localhost';
GRANT SELECT ON `mysql`.`time_zone_name` TO 'cactiuser'@'localhost';
flush privileges;
exit
6. Download and extract the Cacti package
cd /opt/
wget http://www.cacti.net/downloads/cacti-latest.tar.gz
ver=$(tar -tf cacti-latest.tar.gz | head -n1 | tr -d /)
tar -xvf cacti-latest.tar.gz && mv $ver cacti
7. Import the cacti database file
mysql -u root -p cactidb < /opt/cacti/cacti.sql
8. Configure cacti to access the database
nano /opt/cacti/include/config.php
Edit the following to match your install
$database_type = "mysql";
$database_default = "cactidb";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "<password>";
$database_port = "3306";
$database_ssl = false;
9. Change permissions to the cacti directory
chown -R www-data:www-data /opt/cacti/
10. Change permissions to the rra and log directories
chown -R cactiuser /opt/cacti/rra/ /opt/cacti/log/ /opt/cacti/cache/
11. Create a link for the cacti web directory
ln -s /opt/cacti/ /var/www/html/cacti
12. Restart MySQL
systemctl restart mysql
13. Restart Apache
systemctl restart apache2
14. Add the poller to cron.
echo "*/5 * * * * cactiuser php /opt/cacti/poller.php > /dev/null 2>&1" > /etc/cron.d/cacti
15. Connect to the website.
http://<ip address>/cacti
16. Follow the directions on the web page. You may need to alter some MySQL "minimum" settings for Cacti. The items that need to be changed will be in red text and >= value will be provided. These values may very from machine to machine but this can be used as a template.

*Edit: default-time-zone added. Reference MySQL docs for assistance: https://dev.mysql.com/doc/refman/5.7/en ... pport.html
mv /etc/mysql/my.cnf /etc/mysql/my.cnf-bkup
echo "
[mysqld]

max_heap_table_size = 1073741824
max_allowed_packet = 16777216
tmp_table_size = 134217728
join_buffer_size = 134217728
innodb_buffer_pool_size = 4294967296
innodb_doublewrite = OFF
innodb_flush_log_at_timeout = 10
innodb_read_io_threads = 32
innodb_write_io_threads = 16
default-time-zone = 'America/New_York'
" > /etc/mysql/my.cnf
17. Restart MySQL
systemctl restart mysql
18. Restart Apache
systemctl restart apache2
19. Refresh your browser window or navigate back to your Cacti installation
http://<ip address>/cacti
Cacti is now installed. Continue on to install Spine
-----------------------------------------------------

Installing Spine

1. Install dependencies
apt install libmysqlclient-dev libssl-dev libmysqlclient-dev libsnmp-dev help2man libtool make
2. Download spine
3. Extract the package and enter directory
ver=$(tar -tf cacti-spine-latest.tar.gz | head -n1 | tr -d /)
tar -xvf /opt/cacti-spine-latest.tar.gz
cd /opt/$ver/
4. Configure
./configure
5. Make
make
6. Make install
make install
*Optional* Spine is installed into the /usr/local/spine/bin directory which is not part of the system path. If you want to verify that the install worked, you will have to use the full directory.
/usr/local/spine/bin/spine --version
You should get this in return:
SPINE 1.0.? Copyright 2004-2017 by The Cacti Group
7. Edit the spine configuration file
nano /usr/local/spine/etc/spine.conf.dist
Modify this part of the file to match your servers settings
DB_Host localhost
DB_Database cactidb
DB_User cactiuser
DB_Pass <password>
DB_Port 3306
The rest of the setting will have to be made via the web interface.

8. Go to Configuration -> Settings and click on the Paths tab.

Under the Alternate Poller Path, set the following:
Spine Binary File Location = /usr/local/spine/bin/spine
Spine Config File Path = /usr/local/spine/etc/spine.conf.dist
Click Save at the bottom right.

9. Last is to make spine the active poller. Switch to the Poller tab and click on the drop down menu for Poller Type.
Select spine
Click save in the bottom right.

Your Cacti and Spine installation is now complete.

###################################################################################

Upgrading

Along with the modification of the install due to the frequent releases, I also create a simple copy/paste upgrade process. This process is based on the install above so use caution if you installed in any other way. I have this saved in a txt doc with my own db/user/pass options set and just copy/paste every time I need to upgrade.

Be sure not to skip release versions. You must update all in order. Some updates have db changes and if those are skipped, later updates may fail. If you need to install a specific version, find and replace "latest" with the version number. (changing cacti-latest.tar.gz to this cacti-1.1.6.tar.gz)

Systems and installs very but I am able to preform the complete upgrade in between my 5 minute polls. This allows for no "missing" data.
#Download latest version from www.cacti.net

cd ~/
rm cacti-latest.tar.gz | rm –r cactin #removes any previous files that may have a name conflict with the new file.
wget http://www.cacti.net/downloads/cacti-latest.tar.gz
ver=$(tar -tf cacti-latest.tar.gz | head -n1 | tr -d /) #getting the version number
tar -xvf cacti-latest.tar.gz && mv $ver cacti #extracting the file and renaming the directory
chown -R www-data:www-data ~/cacti/ #changing the owner of the new directory
chown -R cactiuser ~/cacti/rra/ ~/cacti/log/ ~/cacti/cache/ #changing the owner of specific sub-directories
systemctl stop mysql apache2 #stopping the services
sed -ie "s/\$database_username =.*;/\$database_username = 'cactiuser';/g" ~/cacti/include/config.php
sed -ie "s/\$database_password =.*;/\$database_password = '<password>';/g" ~/cacti/include/config.php
sed -ie "s/\$database_default =.*;/\$database_default = 'cactidb';/g" ~/cacti/include/config.php
cp -r cacti/* /opt/cacti/ #copy the new files into your cacti directory
systemctl start mysql apache2 #starting services

#Upgrading Spine

cd /opt/
rm –r cacti-spine-* | rm cacti-spine-latest.tar.gz #removes any previous files that may have a name conflict with the new file.
wget http://www.cacti.net/downloads/spine/ca ... est.tar.gz
ver=$(tar -tf cacti-spine-latest.tar.gz | head -n1 | tr -d /) #getting the version number
tar -xvf /opt/cacti-spine-latest.tar.gz #extracting file
cd /opt/$ver/
./configure
make
make install
sed -ie "s/DB_User.*/DB_User cactiuser /g" /usr/local/spine/etc/spine.conf.dist
sed -ie "s/DB_Database.*/DB_Database cactidb /g" /usr/local/spine/etc/spine.conf.dist
sed -ie "s/DB_Pass.*/DB_Pass <password> /g" /usr/local/spine/etc/spine.conf.dist
/usr/local/spine/bin/spine --version #showing version for verification
Last edited by ruehlb on Sat Aug 08, 2020 10:27 pm, edited 14 times in total.
User avatar
phalek
Developer
Posts: 2838
Joined: Thu Jan 31, 2008 6:39 am
Location: Kressbronn, Germany
Contact:

Re: How to install Cacti and Spine ver. 1.0.1 on Ubuntu 16.0

Post by phalek »

In Step 16 for the my.cnf (mysql config) you should also add a setting for the timezone. Example:

Code: Select all

default-time-zone='Europe/Berlin'
Otherwise you may be off some hours on the rrd files ( did see this on my Centos test-system. Initial rrd file update was ok, the second one way off )
Greetings,
Phalek
---
Need more help ? Read the Cacti documentation or my new Cacti 1.x Book
Need on-site support ? Look here Cacti Workshop
Need professional Cacti support ? Look here CereusService
---
Plugins : CereusReporting
User avatar
Osiris
Cacti Guru User
Posts: 1424
Joined: Mon Jan 05, 2015 10:10 am

Re: How to install Cacti and Spine ver. 1.0.1 on Ubuntu 16.0

Post by Osiris »

You missed ownership of the cache directory for realtime, snmpagnt, etc (Step 10). Otherwise perfect!
Before history, there was a paradise, now dust.
MissouriSpartan
Posts: 34
Joined: Fri Dec 16, 2016 12:52 pm

Re: How to install Cacti and Spine ver. 1.0 on Ubuntu 16.04

Post by MissouriSpartan »

This worked! Cacti 1.0.4 is working for me now................except one small thing. All of the interface pages are blank. See the attached screenshots. All pages, no matter what I click on on the left pane, look exactly like that. Just a blank black field.
Attachments
blankPages.JPG
blankPages.JPG (82.64 KiB) Viewed 53732 times
MissouriSpartan
Posts: 34
Joined: Fri Dec 16, 2016 12:52 pm

Re: How to install Cacti and Spine ver. 1.0 on Ubuntu 16.04

Post by MissouriSpartan »

Also, the my.cnf file only has two 'includes' directories in it. There are no places to change the settings that Cacti calls for.
MissouriSpartan
Posts: 34
Joined: Fri Dec 16, 2016 12:52 pm

Re: How to install Cacti and Spine ver. 1.0 on Ubuntu 16.04

Post by MissouriSpartan »

I stand corrected. Turns out 1.0.3-4 are not the greatest on Chrome. It works perfectly on IE, Edge, and Firefox. Bad for me, seeing that I'm a primarily Chrome user. :x
cigamit
Developer
Posts: 3368
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Re: How to install Cacti and Spine ver. 1.0 on Ubuntu 16.04

Post by cigamit »

Its working fine on Chrome for me (I primarily use Chrome for all my developing of Cacti). Please check your javascript console and report any errors you see.
MissouriSpartan
Posts: 34
Joined: Fri Dec 16, 2016 12:52 pm

Re: How to install Cacti and Spine ver. 1.0 on Ubuntu 16.04

Post by MissouriSpartan »

Console is blank. There are no errors
MissouriSpartan
Posts: 34
Joined: Fri Dec 16, 2016 12:52 pm

Re: How to install Cacti and Spine ver. 1.0 on Ubuntu 16.04

Post by MissouriSpartan »

Yup. My bad. Chrome does work. It was an extension I had that was messing with it.
jackie
Cacti User
Posts: 71
Joined: Fri Sep 14, 2007 12:43 pm

Re: How to install Cacti and Spine ver. 1.0 on Ubuntu 16.04

Post by jackie »

Thanks so much for posting this procedure! Worked well and I had cacti up and running in just a few minutes. Kudos!!
spyder13337
Posts: 8
Joined: Mon Jul 27, 2015 10:03 am

Re: How to install Cacti and Spine ver. 1.0 on Ubuntu 16.04

Post by spyder13337 »

perhaps someone can help me it looks like poller is not running i am on debain 8.8 i add the cron job to it and it only runs manually it wont run automatic i chown my cacti directly with -R www-data.www-data

so i know it ok but i do not understand why is not running

*/5 * * * * cacti php /var/www/html/cacti/poller.php > /dev/null 2>&1
yes that is the location of poller.php

i used cacti 8.8b just fine but i wanted to try this new UI it looks nice but i am not sure what i am doing wrong and the log files are not helpful they only show when i run it manually

any Help
User avatar
Osiris
Cacti Guru User
Posts: 1424
Joined: Mon Jan 05, 2015 10:10 am

Re: How to install Cacti and Spine ver. 1.0 on Ubuntu 16.04

Post by Osiris »

Debian unstable has cacti 1.x package. You should try it.
Before history, there was a paradise, now dust.
itkroplis
Posts: 20
Joined: Sun Jun 04, 2017 6:25 am

Re: How to install Cacti and Spine ver. 1.0 on Ubuntu 16.04

Post by itkroplis »

root@DOCKER1:/opt/cacti-spine-1.1.26# apt install libmysqlclient-dev libssl-dev libmysqlclient-dev libsnmp-dev help2man
Reading package lists... Done
Building dependency tree
Reading state information... Done
help2man is already the newest version (1.47.4).
libsnmp-dev is already the newest version (5.7.3+dfsg-1.7).
libssl-dev is already the newest version (1.1.0f-3).
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
libmysqlclient-dev : Depends: libmysqlclient18 (= 5.5.58-0+deb8u1) but 10.2.9+maria~stretch is to be installed
E: Unable to correct problems, you have held broken packages.

After :
apt install apache2 php libapache2-mod-php php-mcrypt php-mysql php-snmp php-xml php-ldap php-mbstring php-gmp snmp php-gd rrdtool mysql-server libssl-dev

For my installed MADIADB! wtf!




I add MySQL sources:

wget https://dev.mysql.com/get/mysql-apt-con ... -1_all.deb
dpkg -i mysql-apt-config_0.8.8-1_all.deb
apt-get update
apt install apache2 php libapache2-mod-php php-mcrypt php-mysql
nilsvandermark
Posts: 45
Joined: Fri Feb 09, 2018 9:31 am

Re: How to install Cacti and Spine ver. 1.0 on Ubuntu 16.04

Post by nilsvandermark »

This is great. Thanks.
I use Fedora, but this still helps.
Keep it going. :D
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests