Cacti Installation and Configuration on Ubuntu 14.04

Cacti Installation and Configuration on Ubuntu 14.04
Cacti is an open-source, network monitoring and graphing tool, that uses the industry-standard data logging tool, RRDtool. Cacti polls services at predetermined intervals and graphs the resulting data. It can graph time-series data of metrics such as CPU load and network bandwidth utilization. It can monitor network traffic by polling a network switch or router interface via Simple Network Management Protocol (SNMP).
The front end can handle multiple users, each with their own graph so it is sometimes used by web hosting providers  to display bandwidth statistics for their clients.

This guide, “Cacti Installation and Configuration on Ubuntu 14.04”, will attempt to install cacti on ubuntu 14.04. If you know me, i love to use the latest and greatest software. But for a change and for personal reasons, i will be using the ubuntu 14.04 instead of the ubuntu 18.04 distro out there.

The installation of cacti on ubuntu involves a series of steps, but do not be scared, it si something we can do without a lot of hassle. So, off we go to install cacti on ubuntu 14.04

Cacti Installation and Configuration on Ubuntu 14.04

After a fresh setup of ubuntu 14.04, do an update using #sudo apt-get update 

If you do not know how to install ubuntu, please follow this guide “https://topnetworkguide.com/install-ubuntu-server-16-04-virtual-box/“.

Now that we have linux installed, we have to install the remaining three items in the LAMP stack.

#apt install -y apache2 mariadb-server mariadb-client php5-mysql libapache2-mod-php5

This will install apache2 web server, mysql or mariadb database and php libraries.

Also install some extensions for php like php-gd php-ldap

#apt-get -y install php5-ldap php5-gd php5-gmp

The php-gd  is a graphics drawing library that provides tools for manipulating image data. The php-ldap will help if you are going to be authenticating against an ldap server.

Now install rrdtool for graphing and the snmp tool.

#apt-get -y install snmp php5-snmp rrdtool librrds-perl

Now create a database named cacti and a user named cactiuser that will have access to the database.

#mysql -u root -p

After entering your password, create a database called cacti, by running the command below:

>create database cacti;

Grant a user called cactiuser access to this cacti database.

>GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY ”enter your cacti password”

Now flush privileges and exit.

The mysql_test_data_timezone.sql file can be found in the /usr/share/mysql directory.

Now, to grant the cactiuser access to the mysql.time_zone_name Table, simply import the mysql_test_data_timezone.sql to mysql database by:

#mysql -u root -p mysql < /usr/share/mysql/mysql_test_data_timezone.sql

Now that we have imported the timezone database to mysql database, grant the cacti user access to this database.

#mysql -u root -p

>GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost;

>flush privileges;

>exit

flush privileges

Make some changes in your my.cnf file. This will help to improve performance of your database. Enter the code below in the [mysqld] section.

Navigate to #nano /etc/mysql/my.cnf

max_heap_table_size = 181M

tmp_table_size = 64M

join_buffer_size = 64M

innodb_buffer_pool_size = 904M

innodb_doublewrite = off

innodb_file_per_table = on

innodb_additional_mem_pool_size=96M

innodb_flush_log_at_trx_commit = 2

Also navigate to #nano /etc/php5/apache2/php.ini and set your timezone

edit php.ini file

INSTALL CACTI USING THE TAR.GZ FILE FROM CACTI OFFICIAL SITE.

To install the latest version of cacti, which happens to be cacti-1.1.38, go to https://cacti.net. Hit download button and copy out the link for the tar.gz file.

https://topnetworkguide.com/wp-content/uploads/2018/11/link-to-download-latest-cacti.png

Using wget, download the cacti file onto your ubuntu machine.

#wget https://www.cacti.net/downloads/cacti-1.1.38.tar.gz

download cacti-1.1.38

Extract the tar file and cd into the extracted file. Move all contents from the cacti folder to /opt folder.

#tar -zxvf cacti-1.1.38.tar.gz

#mkdir /opt/cacti

#cd cacti-1.1.38

#mv cacti-1.* /opt/cacti

Import the default database to cacti database.

#mysql -u root -p cacti < /opt/cacti/cacti.sql

Edit the config.php file and enter in the correct cacti password you used when creating and granting the cactiuser permissions in mysql.

#nano /opt/cacti/include/config.php  

Now create a cronjob that executes every 5 minuites. This job collects data every 5 mins.

#nano /etc/crontab

edit crontab file

Enter in the code:

*/5 * * * * www-data php /opt/cacti/poller.php > /dev/null 2>&1

Its time to simply copy the configuration code below and paste in sites-available/cacti.config file

#nano /etc/apache2/sites-available/cacti.conf

Alias /cacti /opt/cacti

  <Directory /opt/cacti>
      Options +FollowSymLinks
      AllowOverride None
      <IfVersion >= 2.3>
      Require all granted
      </IfVersion>
      <IfVersion < 2.3>
      Order Allow,Deny
      Allow from all
      </IfVersion>

   AddType application/x-httpd-php .php

<IfModule mod_php.c>
      php_flag magic_quotes_gpc Off
      php_flag short_open_tag On
      php_flag register_globals Off
      php_flag register_argc_argv On
      php_flag track_vars On
      # this setting is necessary for some locales
      php_value mbstring.func_overload 0
      php_value include_path .
 </IfModule>

  DirectoryIndex index.php
</Directory>

 

Enable the just configured cacti site by, #sudo a2ensite cacti

Now restart mysql and apache2.

#sudo service apache2 reload

#sudo service mysql restart

start mysql service

Now create a log file in opt/cacti and make the following files writable. The files include, cacti/log, cacti/resource, cacti/cache, cacti/scripts, cacti/rra. All these files can be found in the /opt directory.

#touch /opt/cacti/log/cacti.log

#chown -R www-data:www-data /opt/cacti/log/

#chown -R www-data:www-data /opt/cacti/resource/

#chown -R www-data:www-data /opt/cacti/cache/

#chown -R www-data:www-data /opt/cacti/scripts/

#chown -R www-data:www-data /opt/cacti/rra

allow apache users to write to cacti

Now visit http://ip address of cacti server/cacti. The not so familiar screen is presented.

cacti license agreement

Install the cacti either as a primary server of new remote poller.

Accept the license agreement and click next.

preinstallation checks on cacti

These checks in green prove that all is ok. Hit next to continue. You might get a red mark about upgrading mariadb. Simply ignore. That is not an issue for now.

Since spine was not installed, we also get a red mark indicating this.

Also the directory permission checks shows that all our files in opt/cacti are writable as shown.

Select all the templates that come with cacti-1.1,38 and hit finish to install them.

Now the login screen displays. Enter the login details of admin for username and admin for password.

Cacti forces you to change your password.

The dashboard shown under is the result of all our hard work so far.

cacti dashboard

It will not be fair if we say we didnt have to go through some hassle while installing cacti. But our efforts paid out in the end. We now have the latest version of cacti sitting on top of our ubuntu server. While the dashboard may not  be much at the moment, we have plans to add  and monitor hosts in the future. So, stay connected and we should soon see our dashboard grow to fully manage whatever we want to monitor.

 

Did You Enjoy What You Read? Sign Up To Our News Letter
I agree to have my personal information transfered to MailChimp ( more information )
Join over 1.000 visitors who are receiving our newsletter and learn how to design networks that work using open source technology and commercial offerings. Also learn how to proactively defend against security threats.
We hate spam. Your email address will not be sold or shared with anyone else.
Share This.