How to Install Cacti Server on Ubuntu 19.10 - GoTechTalk


Saturday, April 25, 2020

How to Install Cacti Server on Ubuntu 19.10

By Sudarshan Yerunkar | Tweet to @SY_Offical | 🛍 Support me with your Amazon purchases:

How to Install Cacti Server on Ubuntu Server 18.04 and 19.10

Cacti is an open-source network monitoring tool. Cacti controls RRDTool’s data storage and graphing functionality, easy to use web interface which can be used for small LAN installations up to complex networks, servers
and networking devices.

This  can be installed on Ubuntu 18.04 and 19.10 as well
Let's with the server packages update.        

Switch to root user : sudo su
apt-get update

To start we will  install Apache, MySQL and PHP packages on your machine.
apt install -y apache2 mariadb-server mariadb-client php-mysql libapache2-mod-php

Mysql database tuning for better performance
nano /etc/mysql/mariadb.conf.d/50-server.cnf

Add/Update the below settings in [mysqld] section.
collation-server = utf8mb4_unicode_ci

Set Timezone

We will edit the following ini files to set a timezone.
nano /etc/php/7.3/apache2/php.ini
nano /etc/php/7.3/cli/php.ini

date.timezone = Asia/kolkata
memory_limit = 512M
max_execution_time = 60

Restart MariaDB service.
systemctl restart mariadb

Create a database for Cacti
mysql -u root -p
create database cacti;

Grant permission to the newly created database.
GRANT ALL ON cacti.* TO user@localhost IDENTIFIED BY 'password';
flush privileges;

The newly created database user should have access to the mysql.time_zone_name Table.
mysql -u root -p mysql < /usr/share/mysql/mysql_test_data_timezone.sql

Lets log in again  to MySQL.
mysql -u root -p
GRANT SELECT ON mysql.time_zone_name TO user@localhost;
flush privileges;

Now lets Install Cacti.
 apt-get install snmp snmpd snmp-mibs-downloader rrdtool cacti cacti-spine

Configure SNMP
nano /etc/snmp/snmp.conf
mibs : to # mibs :

Configure SNMP community name by editing
nano  /etc/snmp/snmpd.conf
rocommunity public localhost

Disable public access by commenting below lines
rocommunity public default -V systemonly
rocommunity6 public default -V systemonly
# rocommunity public default -V systemonly
# rocommunity6 public default -V systemonly

Restart snmpd service
systemctl restart snmpd

Configure Cacti Server

Now we will need to edit the Cacti config file to specify the database type, database name, MySQL hostname, user, and password information.
nano /usr/share/cacti/site/include/config.php

Make the changes accordingly.
/* make sure these values reflect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "user";
$database_password = "password";
$database_port = "3306";
$database_ssl = false;
mysql -u user -p cacti < /usr/share/doc/cacti/cacti.sql

Edit the Apache configuration file to perform the remote installation.
nano /etc/apache2/sites-available/cacti.conf
Use the following configuration.
Alias /cacti /opt/cacti

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

   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 .

  DirectoryIndex index.php

Enable the created virtual host.
systemctl enable apache2
a2ensite cacti

Restart Apache services.
systemctl restart apache2

Grant Permissions to following directories.
chown -R www-data:www-data /usr/share/cacti/site/resource/snmp_queries/
chown -R www-data:www-data /usr/share/cacti/site/resource/script_server/
chown -R www-data:www-data /usr/share/cacti/site/resource/script_queries/
chown -R www-data:www-data /usr/share/cacti/site/scripts

Setup Cacti
Login to Cacti to set up Cacti installation.
Cacti username and password

Username: admin

Password: admin

No comments:

Post a Comment