Linuxmonitoring tool
How to Install and Configure Cacti on Ubuntu 18 LTS

In this tutorial, we see how to Install and Configure Cacti on Ubuntu 18 LTS. Cacti is one of the core network monitoring tool used for monitoring servers.
Cacti is one of the opensource free web-based network monitoring tools. Cacti as inbuild features which provides graphs easy to analyze and plan for further Infra scale as per the alerts.
Steps to install Cacti on Ubuntu 18.04
Let’s see what all Prerequisites for cacti on ubuntu
Take the access of Ubuntu server via ssh with root user or switch to root user.
1 2 3 |
$ sudo su - OR $ su - |
Now, update the ubuntu repository using apt cmd.
1 2 3 |
$ apt update OR $ sudo apt update |
Now, Install Apache, PHP and MySQL package on Ubuntu machine.
1 2 3 4 5 |
$ apt install -y php-mysql apache2 mariadb-client mariadb-server libapache2-mod-php $ apt install -y php-gd php-gmp php-xml php-ldap php-mbstring $ apt install -y snmp php-snmp rrdtool librrds-perl |
Now, Create Cacti Database on Ubuntu server
Access Database follow commands:
1 |
$ mysql -u root -p |
syntax: create databse <databse-name>;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
create database cacti; Grant permission cacti database GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactipassword'; flush privileges; exit mysql -u root -p mysql < /usr/share/mysql/mysql_test_data_timezone.sql GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost; flush privileges; exit |
Recommended settings for the database to get better performance:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
nano /etc/mysql/mariadb.conf.d/50-server.cnf #Add the below variables in [mysqld] section. collation-server = utf8mb4_unicode_ci max_heap_table_size = 128M tmp_table_size = 64M join_buffer_size = 64M innodb_buffer_pool_size = 512M innodb_doublewrite = off innodb_additional_mem_pool_size=96M innodb_flush_log_at_timeout = 3 innodb_read_io_threads = 32 innodb_write_io_threads = 16 |
Set Timezone in php.ini file.
1 2 3 4 5 |
$ nano /etc/php/7.2/apache2/php.ini #Add below lines date.timezone = EST |
Download Cacti for ubuntu 18.04
1 2 3 |
$ cd /opt $ wget https://www.cacti.net/downloads/cacti-latest.tar.gz |
Now, Extract the downloaded Cacti archive
1 2 3 |
$ tar -zxvf cacti-latest.tar.gz $ mv cacti-1* /opt/cacti |
Import the cacti.sql file as a default Cacti database data.
1 |
$ mysql -u root -p cacti < /opt/cacti/cacti.sql |
update the Cacti config file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
nano /opt/cacti/include/config.php Make the changes respectevly. /* make sure these values are your actual database/host/user/password */ $database_type = "mysql"; $database_default = "cacti"; $database_hostname = "localhost"; $database_username = "cactiuser"; $database_password = "cactipassword"; $database_port = "3306"; $database_ssl = false; |
Edit the crontab file.
Add below entry in crontab, For every five min cacti can poll
1 2 3 |
nano /etc/crontab */5 * * * * www-data php /opt/cacti/poller.php > /dev/null 2>&1 |
For remote web installation update Apache config file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
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 virtual host
1 |
$ a2ensite cacti |
Now, restart Apache and mysql service:
1 2 3 |
$ systemctl restart mysql $ systemctl restart apache2 |
Create Log file and give the permission to Apache user to write data to cacti directory.
1 2 3 4 5 6 7 8 9 10 11 |
$ 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 |
Steps to Setup Cacti
Goto Browser and access cacti as follows:
http://your.ip.address/cacti
Cacti Pre-Installation Checks
Click on Next
Now select the new primary server for new installation and click next.
Display if any package is missing
Checks if any permission issue on a directory
Now, Select the Cacti monitoring template and click on finish
Once you have setup the Cacti Installation, Goto Dashboard.
Default username: admin
Default password: admin
Note: Change the password once you login.
Once you login you will see Cacti Dashboard
To see graphs of local machine Goto Graphs > Default tree > local Linux machine.
In this tutorial, you learned How to Install and Configure Cacti on Ubuntu 18 LTS.