How to install and setup Cacti in Ubuntu

To install and setup Cacti in Ubuntu

Cacti is an entire network graphing solution designed for data storage and graphing functionality. It can graph network bandwidths with SNMP, Shell or Perl scripts. This tool is programmed in " C" language.It backups and stores the information on " .rrd" files and auto deletes the old backups. Installation of Cacti in Ubuntu is explained in this manual.

Features

  • Unlimited graphical notations.
  • Flexible data sources.
  • Auto-padding support for graphs.
  • Graph data manipulation.
  • Custom data-gathering scripts.
  • Built-in SNMP support.
  • Graph templates.
  • Data source templates.
  • Host templates.
  • User-based management and security.
  • Tree, list, and preview views of graph data.


To install LAMP

Cacti supports only MySQL-Server-5.6. So before installing LAMP, it is necessary to add and update the necessary repository for installing ' MySQL-Server-5.6' .

root@linuxhelp1:~# add-apt-repository ' deb http://archive.ubuntu.com/ubuntu trusty universe'  


After adding the necessary repos, update the newly added repository.

root@linuxhelp1:~# apt-get update 
Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [94.5 kB]
Ign:2 http://archive.ubuntu.com/ubuntu trusty InRelease                        
Hit:3 http://in.archive.ubuntu.com/ubuntu xenial InRelease                     
Get:4 http://archive.ubuntu.com/ubuntu trusty Release [58.5 kB]                                           
Hit:5 http://in.archive.ubuntu.com/ubuntu xenial-updates InRelease                       
Hit:6 http://in.archive.ubuntu.com/ubuntu xenial-backports InRelease                                                 
Get:7 http://in.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [408 kB]                                
Get:8 http://in.archive.ubuntu.com/ubuntu xenial-updates/main i386 Packages [402 kB]                             
Get:9 http://in.archive.ubuntu.com/ubuntu xenial-updates/main Translation-en [155 kB]                   
.
.
.
Get:29 http://security.ubuntu.com/ubuntu xenial-security/multiverse Translation-en [628 B]                                          
Get:31 http://archive.ubuntu.com/ubuntu trusty/universe i386 Packages [5,866 kB]                                                    
Fetched 12.5 MB in 41s (300 kB/s)                                                                                                   
Reading package lists... Done


After updating the repositories, start installing the LAMP packages.

root@linuxhelp1:~# apt-get install apache2 mysql-server-5.6 php libapache2-mod-php -y 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  apache2-bin apache2-data apache2-utils libaio1 libapache2-mod-php7.0 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap
  libdbd-mysql-perl libdbi-perl libhtml-template-perl liblua5.1-0 libmysqlclient20 libterm-readkey-perl mysql-client-5.6
  mysql-client-core-5.6 mysql-common mysql-server-core-5.6 php-common php7.0 php7.0-cli php7.0-common php7.0-json php7.0-opcache
  php7.0-readline
Suggested packages:
  apache2-doc apache2-suexec-pristine | apache2-suexec-custom php-pear libmldbm-perl libnet-daemon-perl libsql-statement-perl
  libipc-sharedcache-perl mailx tinyca
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils libaio1 libapache2-mod-php libapache2-mod-php7.0 libapr1 libaprutil1
  libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl libdbi-perl libhtml-template-perl liblua5.1-0 libmysqlclient20
  libterm-readkey-perl mysql-client-5.6 mysql-client-core-5.6 mysql-common mysql-server-5.6 mysql-server-core-5.6 php php-common
  php7.0 php7.0-cli php7.0-common php7.0-json php7.0-opcache php7.0-readline
0 upgraded, 30 newly installed, 0 to remove and 401 not upgraded.
Need to get 26.6 MB of archives.
After this operation, 185 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu trusty/universe amd64 mysql-client-core-5.6 amd64 5.6.16-1~exp1 [4,084 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 libapr1 amd64 1.5.2-3 [86.0 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 libaprutil1 amd64 1.5.4-1build1 [77.1 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 libaprutil1-dbd-sqlite3 amd64 1.5.4-1build1 [10.6 kB]
Get:5 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 libaprutil1-ldap amd64 1.5.4-1build1 [8,720 B]
Get:6 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 liblua5.1-0 amd64 5.1.5-8ubuntu1 [102 kB]
.
.
.
Now enter the password for the mysql admin


.
.
.
Creating config file /etc/php/7.0/mods-available/readline.ini with new version
Setting up php7.0-cli (7.0.8-0ubuntu0.16.04.3) ...
update-alternatives: using /usr/bin/php7.0 to provide /usr/bin/php (php) in auto mode
update-alternatives: using /usr/bin/phar7.0 to provide /usr/bin/phar (phar) in auto mode
update-alternatives: using /usr/bin/phar.phar7.0 to provide /usr/bin/phar.phar (phar.phar) in auto mode

Creating config file /etc/php/7.0/cli/php.ini with new version
Setting up libapache2-mod-php7.0 (7.0.8-0ubuntu0.16.04.3) ...

Creating config file /etc/php/7.0/apache2/php.ini with new version
Module mpm_event disabled.
Enabling module mpm_prefork.
apache2_switch_mpm Switch to prefork
apache2_invoke: Enable module php7.0
Setting up libapache2-mod-php (1:7.0+35ubuntu6) ...
Setting up libhtml-template-perl (2.95-2) ...
Setting up php7.0 (7.0.8-0ubuntu0.16.04.3) ...
Setting up php (1:7.0+35ubuntu6) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-4ubuntu4) ...
Processing triggers for ufw (0.35-0ubuntu2) ...


Then install the snmp, snmpd and rrdtools by applying the below request.

root@linuxhelp1:~# apt-get install snmp snmpd rrdtool -y 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libdbi1 librrd4
Suggested packages:
  librrds-perl snmptrapd
The following NEW packages will be installed:
  libdbi1 librrd4 rrdtool snmp snmpd
0 upgraded, 5 newly installed, 0 to remove and 401 not upgraded.
Need to get 775 kB of archives.
After this operation, 2,464 kB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 libdbi1 amd64 0.9.0-4 [27.8 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 librrd4 amd64 1.5.5-4 [180 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 snmp amd64 5.7.3+dfsg-1ubuntu4 [154 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 snmpd amd64 5.7.3+dfsg-1ubuntu4 [57.1 kB]
Get:5 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 rrdtool amd64 1.5.5-4 [356 kB]
Fetched 775 kB in 8s (89.1 kB/s)                                                                                                    
Preconfiguring packages ...
Selecting previously unselected package libdbi1:amd64.
(Reading database ... 175119 files and directories currently installed.)
Preparing to unpack .../libdbi1_0.9.0-4_amd64.deb ...
Unpacking libdbi1:amd64 (0.9.0-4) ...
Selecting previously unselected package librrd4:amd64.
.
.
.
Setting up snmp (5.7.3+dfsg-1ubuntu4) ...
Setting up snmpd (5.7.3+dfsg-1ubuntu4) ...
adduser: Warning: The home directory `/var/lib/snmp'  does not belong to the user you are currently creating.
update-rc.d: warning: start and stop actions are no longer supported  falling back to defaults
update-rc.d: warning: stop runlevel arguments (1) do not match snmpd Default-Stop values (0 1 6)
Setting up rrdtool (1.5.5-4) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-4ubuntu4) ...

To install Cacti

Now install the Cacti - Network graphing solution by executing the following command.

root@linuxhelp1:~# apt-get install cacti cacti-spine -y 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  dbconfig-common dbconfig-mysql javascript-common libjs-jquery libjs-jquery-cookie libjs-jquery-ui
  libjs-jquery-ui-theme-ui-lightness libphp-adodb php-mbstring php-mysql php-snmp php-xml php7.0-mbstring php7.0-mysql php7.0-snmp
  php7.0-xml
Suggested packages:
  php-ldap moreutils snmp-mibs-downloader mysql-server | mariadb-server libjs-jquery-ui-docs php-adodb
The following NEW packages will be installed:
  cacti cacti-spine dbconfig-common dbconfig-mysql javascript-common libjs-jquery libjs-jquery-cookie libjs-jquery-ui
  libjs-jquery-ui-theme-ui-lightness libphp-adodb php-mbstring php-mysql php-snmp php-xml php7.0-mbstring php7.0-mysql php7.0-snmp
  php7.0-xml
0 upgraded, 18 newly installed, 0 to remove and 401 not upgraded.
Need to get 4,150 kB of archives.
After this operation, 14.6 MB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 dbconfig-common all 2.0.4ubuntu1 [582 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu xenial/universe amd64 dbconfig-mysql all 2.0.4ubuntu1 [1,038 B]
Get:3 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 javascript-common all 11 [6,066 B]                                      
Get:4 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 libjs-jquery all 1.11.3+dfsg-4 [161 kB]                                 
Get:5 http://in.archive.ubuntu.com/ubuntu xenial/universe amd64 libjs-jquery-cookie all 10-2ubuntu2 [6,764 B]                       
Get:6 http://in.archive.ubuntu.com/ubuntu xenial/universe amd64 libjs-jquery-ui all 1.10.1+dfsg-1 [458 kB]                          
Get:7 http://in.archive.ubuntu.com/ubuntu xenial/universe amd64 libjs-jquery-ui-theme-ui-lightness all 1.8.24+dfsg-1 [33.7 kB]      
Get:8 http://in.archive.ubuntu.com/ubuntu xenial/universe amd64 libphp-adodb all 5.20.3-1ubuntu1 [438 kB]                     
.
.
.
For configuring the catci



.
.
.

Creating config file /etc/dbconfig-common/cacti.conf with new version

Creating config file /etc/cacti/debian.php with new version
granting access to database cacti for cacti@localhost: success.
verifying access for cacti@localhost: success.
creating database cacti: success.
verifying database cacti exists: success.
populating database via sql...  done.
dbconfig-common: flushing administrative password

Creating config file /etc/apache2/conf-available/cacti.conf with new version

Creating config file /etc/lighttpd/conf-available/20-cacti.conf with new version
apache2_invoke: Enable configuration cacti
Setting up cacti-spine (0.8.8b-1ubuntu1.1) ...

Creating config file /etc/cacti/spine.conf with new version
Processing triggers for libapache2-mod-php7.0 (7.0.8-0ubuntu0.16.04.3) ...


Then restart the snmpd, mysql and apache2 services.

root@linuxhelp1:~# service snmpd restart
root@linuxhelp1:~# service mysql restart
root@linuxhelp1:~# service apache2 restart 


Trigger the web browser and enter the URL http://< IP_address> /cacti

To proceed further click Next.

Choose your preferred installation type and click Next.

Verify all the values, if everything seems to be fine then click Finish.

Enter Cacti User Name and Password to Login.


The Cacti environment appears as follows.

To view the Graphical representation of networks, click on Graph

Tag : Cacti
FAQ
Q
Dear Support,
I have a problem on show cacti.log on cacti. It say “Error /usr/share/cacti/log/cacti.log is not readable“. I try to give full permission to user apache and cacti but it still got same error.
[root@localhost log]# ll /usr/share/cacti/log/cacti.log
-rwxrwxrwx. 1 apache cacti 1606 Nov 26 03:00 /usr/share/cacti/log/cacti.log
A
I think you should assign permission apache user like:

# chown -R apache:apache cacti.log
Q
mysql -u cacti -p raju < /usr/share/doc/cacti-1.1.28/cacti.sql
Enter password:
ERROR 1044 (42000): Access denied for user 'cacti'@'localhost' to database 'raju'
hi. I am getting the above error. can you please help me with this?
A
Better to import Cacti.sql to Cacti database using root and then grant permission to whole Cacti database as cacti user..
Q
Hi,

Getting below error, please advise, thanks

# mysql -u cacti -p cacti < /usr/share/doc/cacti-1.1.24/cacti.sql
Enter password:
ERROR 1045 (28000): Access denied for user 'cacti'@'localhost' (using password: YES)

Forbidden

I am getting an error.

Error: your MYSQL timezone database is not populated. please populate the database before proceeding? what will do?
A
Try these commands to fix that MYSQL timezone database is not populated error.

# cd cacti/cli
# php repair_database.php --force
# php upgrade_database.php

it will solve your problem..
Q
How do I create traffic graphs?
A
Click Devices on Cacti's menu. Click Add to add a new device. Type a description, hostname, management IP, and SNMP community. Make sure to select "Generic SNMP-enabled Host" un
Q
when i tape ‘yum install cacti’ it says that no package cacti are available. What should i do ?!
A
First, you need to enable EPEL Repository in your system to install Cacti package.

# yum install epel-release
# yum install cacti