{"id":7166,"date":"2020-10-28T22:36:24","date_gmt":"2020-10-28T19:36:24","guid":{"rendered":"https:\/\/kifarunix.com\/?p=7166"},"modified":"2024-03-14T23:20:59","modified_gmt":"2024-03-14T20:20:59","slug":"easily-install-and-setup-cacti-on-ubuntu-20-04","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/easily-install-and-setup-cacti-on-ubuntu-20-04\/","title":{"rendered":"Easily Install and Setup Cacti on Ubuntu 20.04"},"content":{"rendered":"\n
In this tutorial, you will learn how to easily install and setup Cacti on Ubuntu 20.04. Cacti<\/a> is a complete frontend to RRDTool. <\/em>RRDTool is a time-series data storage and display system. It stores and display time-series data (e.g. network bandwidth, machine-room temperature, server load average) in a database. It stores the data in Round Robin Databases (RRDs), a very compact way that will not expand over time. RRDtool processes the extracted data to enforce a certain data density, allowing for useful graphical representation of data values. The Cacti frontend is completely PHP driven. Along with being able to maintain Graphs, Data Sources, and Round Robin Archives in a database, cacti handles the data gathering. There is also SNMP support for those used to creating traffic graphs with MRTG<\/em>.<\/p>\n\n\n\n Below are the requirements for setting up Cacti;<\/p>\n\n\n\n To begin with, ensure your system package cache is up-to-date;<\/p>\n\n\n\n As stated in the requirements section above, RRDTool 1.4+ is recommended for use with Cacti. In the default Ubuntu 20.04 repos, RRDTool 1.7.2 is available.<\/p>\n\n\n\n Therefore, you can install RRDTool on Ubuntu 20.04 by running the command below;<\/p>\n\n\n\n You also need to install SNMP by running the command below;<\/p>\n\n\n\n In this setup, we will use MariaDB 10.5 as our database backend. Thus, run the commands below to install and setup MariaDB 10.5 on Ubuntu 20.04;<\/p>\n\n\n\n MariaDB ships with initial security script which can be run to remove test databases, disallow remote root login, remove anonymous users.<\/p>\n\n\n\n Login to MariaDB and create the Cacti database and database user. Be sure to replace the database name and the username and password accordingly.<\/p>\n\n\n\n Reload privileges table and exit the database;<\/p>\n\n\n\n Open the Save and exit the file and restart MariaDB;<\/p>\n\n\n\n Run the command below to install PHP and other required modules;<\/p>\n\n\n\n Set the PHP timezone;<\/p>\n\n\n\n Maximum execution time;<\/p>\n\n\n\n Set the Memory limit;<\/p>\n\n\n\n Similarly, set the timezone on PHP INI CLI configuration.<\/p>\n\n\n\n In this setup, we are using Apache HTTP Server with Cacti. Note that when you install PHP, Apache gets installed along with it. If not already installed, then you can install it as follows;<\/p>\n\n\n\n Next, install Cacti. As much as the package is available on the default Ubuntu Universe repos, it is the latest stable release.<\/p>\n\n\n\n As of this writing, the latest stable version is 1.2.14<\/strong>, released 08\/02\/20.<\/p>\n\n\n\n Hence, download and extract Cacti tarball archive to your default Web root directory.<\/p>\n\n\n\n In this setup, am gonna use \/var\/www\/html\/cacti as the web root directory for Cacti;<\/p>\n\n\n\n Set the ownership of the Cacti web root directory to Apache HTTP server user;<\/p>\n\n\n\n Import the default Cacti database from the extracted web root directory to the new database created above for Cacti;<\/p>\n\n\n\n Import the timezone data into MariaDB database and grant Cacti database user SELECT right access to Once the import is done, open the Cacti configuration file, Next, create an Apache configuration for Cacti;<\/p>\n\n\n\n Save and exit the file.<\/p>\n\n\n\n Check Apache configuration syntax;<\/p>\n\n\n\n If you get, Open Apache on UFW, if at all UFW is running;<\/p>\n\n\n\n You can now access Cacti Web interface via the URL, Login using the default credentials, Upon login, you are prompted to reset your password. Please reset and proceed.<\/p>\n\n\n\n Accept End User License Agreement;<\/p>\n\n\n\n Click Begin to perform Pre-installation checks. If any error, please fix before you can proceed.<\/p>\n\n\n\n Installation type<\/p>\n\n\n\n Directory Permission Checks<\/p>\n\n\n\n Critical Binary Locations and Versions.<\/p>\n\n\n\n Input Validation Whitelist Protection<\/p>\n\n\n\n Default Profile and Automation Network<\/p>\n\n\n\n Template Setup<\/p>\n\n\n\n Server, Database collation and Table Setup.<\/p>\n\n\n\n Cacti Installation: Select Confirm<\/strong> Installation<\/strong> and click install<\/strong> to install Cacti on Ubuntu 20.04.<\/p>\n\n\n\n Once the installation completes, click Get started to access Cacti web interface.<\/p>\n\n\n\n Cacti Web Console;<\/p>\n\n\n\n Installing Cacti Under Unix<\/a><\/p>\n\n\n\n Install Zabbix 4.x from Sources on Debian 10 Buster<\/a><\/p>\n\n\n\n Install ELK Stack on Ubuntu 20.04<\/a><\/p>\n\n\n\n Install and Setup Nagios Core on Ubuntu 20.04<\/a><\/p>\n\n\n\nCacti Feature Highlights<\/h3>\n\n\n\n
\n
Installing Cacti on Ubuntu 20.04<\/h2>\n\n\n\n
Prerequisites<\/h3>\n\n\n\n
\n
Run System Update<\/h3>\n\n\n\n
apt update<\/code><\/pre>\n\n\n\n
Install RRDTool on Ubuntu 20.04<\/a><\/h3>\n\n\n\n
apt-cache policy rrdtool<\/code><\/pre>\n\n\n\n
\nrrdtool:\n Installed: (none)\n Candidate: 1.7.2-3build2\n Version table:\n 1.7.2-3build2 500\n 500 http:\/\/ke.archive.ubuntu.com\/ubuntu focal\/main amd64 Packages\n<\/code><\/pre>\n\n\n\n
apt install rrdtool -y<\/code><\/pre>\n\n\n\n
apt install snmpd snmp snmp-mibs-downloader libsnmp-dev<\/code><\/pre>\n\n\n\n
Install and Setup MySQL\/MariaDB Database on Ubuntu 20.04<\/a><\/h3>\n\n\n\n
Install MariaDB 10.5 on Ubuntu 20.04<\/h4>\n\n\n\n
apt-key adv --fetch-keys 'https:\/\/mariadb.org\/mariadb_release_signing_key.asc'<\/code><\/pre>\n\n\n\n
add-apt-repository 'deb [arch=amd64] http:\/\/mariadb.mirror.globo.tech\/repo\/10.5\/ubuntu focal main'<\/code><\/pre>\n\n\n\n
apt update<\/code><\/pre>\n\n\n\n
apt install mariadb-server mariadb-client<\/code><\/pre>\n\n\n\n
Securing MariaDB<\/h4>\n\n\n\n
mysql_secure_installation<\/code><\/pre>\n\n\n\n
Create Cacti Database and Database User<\/h4>\n\n\n\n
mysql<\/code><\/pre>\n\n\n\n
create database rrdtooldb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;<\/code><\/pre>\n\n\n\n
grant all on rrdtooldb.* to rrdtooladmin@localhost identified by 'RRDTOOLDB_pass';<\/code><\/pre>\n\n\n\n
flush privileges;\nquit<\/code><\/pre>\n\n\n\n
Fine-tune MariaDB Database for Cacti<\/h4>\n\n\n\n
\/etc\/mysql\/mariadb.conf.d\/50-server.cnf<\/strong><\/code> file and add the following lines under the
[mysqld]<\/strong><\/code> section to optimize the database for Cacti.<\/p>\n\n\n\n
vim \/etc\/mysql\/mariadb.conf.d\/50-server.cnf<\/code><\/pre>\n\n\n\n
\n...\n# utf8 4-byte character set. See also client.cnf\ncharacter-set-server = utf8mb4\ncharacter_set_client = utf8mb4\ncollation-server = utf8mb4_unicode_ci\n...\n...\nmax_heap_table_size=128M\ntmp_table_size=128M\njoin_buffer_size=256M\ninnodb_file_format=Barracuda\ninnodb_large_prefix=1\ninnodb_buffer_pool_size=2048M\ninnodb_flush_log_at_timeout=3\ninnodb_read_io_threads=32\ninnodb_write_io_threads=16\ninnodb_buffer_pool_instances=17\ninnodb_io_capacity=5000\ninnodb_io_capacity_max=10000\n...\n<\/code><\/pre>\n\n\n\n
systemctl restart mariadb<\/code><\/pre>\n\n\n\n
Install PHP and Other Required Modules<\/h3>\n\n\n\n
apt install php php-mysql php-curl php-net-socket php-gd php-intl php-pear php-imap php-memcache libapache2-mod-php php-pspell php-tidy php-xmlrpc php-snmp php-mbstring gettext php-gmp php-json php-xml php-ldap<\/code><\/pre>\n\n\n\n
vim \/etc\/php\/7.4\/apache2\/php.ini<\/code><\/pre>\n\n\n\n
[Date]\n; Defines the default timezone used by the date functions\n; http:\/\/php.net\/date.timezone\ndate.timezone = Asia\/Qatar<\/code><\/pre>\n\n\n\n
...\n; Maximum execution time of each script, in seconds\n; http:\/\/php.net\/max-execution-time\n; Note: This directive is hardcoded to 0 for the CLI SAPI\nmax_execution_time = 60\n...<\/code><\/pre>\n\n\n\n
...\n; Maximum amount of memory a script may consume (128MB)\n; http:\/\/php.net\/memory-limit\nmemory_limit = 400M\n...<\/code><\/pre>\n\n\n\n
vim \/etc\/php\/7.4\/cli\/php.ini<\/code><\/pre>\n\n\n\n
[Date]\n; Defines the default timezone used by the date functions\n; http:\/\/php.net\/date.timezone\ndate.timezone = \"Asia\/Qatar\"<\/code><\/pre>\n\n\n\n
Install Apache Web Server on Ubuntu 20.04<\/h3>\n\n\n\n
apt install apache2<\/code><\/pre>\n\n\n\n
Install Cacti<\/h3>\n\n\n\n
apt-cache policy cacti<\/code><\/pre>\n\n\n\n
cacti:\n Installed: (none)\n Candidate: 1.2.10+ds1-1ubuntu1\n Version table:\n 1.2.10+ds1-1ubuntu1 500\n 500 http:\/\/ke.archive.ubuntu.com\/ubuntu focal\/universe amd64 Packages<\/code><\/pre>\n\n\n\n
wget https:\/\/www.cacti.net\/downloads\/cacti-latest.tar.gz<\/code><\/pre>\n\n\n\n
mkdir \/var\/www\/html\/cacti<\/code><\/pre>\n\n\n\n
tar xzf cacti-latest.tar.gz -C \/var\/www\/html\/cacti --strip-components=1<\/code><\/pre>\n\n\n\n
chown -R www-data: \/var\/www\/html\/cacti\/<\/code><\/pre>\n\n\n\n
Import the default Cacti database<\/h4>\n\n\n\n
mysql -u rrdtooladmin -p -D rrdtooldb < \/var\/www\/html\/cacti\/cacti.sql<\/code><\/pre>\n\n\n\n
Import timezone data into MariaDB database<\/h4>\n\n\n\n
mysql.time_zone_name<\/code> table;<\/p>\n\n\n\n
mysql -u root -p mysql < \/usr\/share\/mysql\/mysql_test_data_timezone.sql<\/code><\/pre>\n\n\n\n
mysql -u root<\/code><\/pre>\n\n\n\n
grant select on mysql.time_zone_name to rrdtooladmin@localhost;<\/code><\/pre>\n\n\n\n
quit<\/code><\/pre>\n\n\n\n
Configure Cacti Database Connection details<\/h4>\n\n\n\n
\/var\/www\/html\/cacti\/include\/config.php<\/strong><\/code>, and define the database connection details.<\/p>\n\n\n\n
vim \/var\/www\/html\/cacti\/include\/config.php<\/code><\/pre>\n\n\n\n
\n...\n\/*\n * Make sure these values reflect your actual database\/host\/user\/password\n *\/\n\n$database_type = 'mysql';\n$database_default = 'rrdtooldb';\n$database_hostname = 'localhost';\n$database_username = 'rrdtooladmin';\n$database_password = 'RRDTOOLDB_pass';\n$database_port = '3306';\n<\/code><\/pre>\n\n\n\n
Create Cacti Apache Configuration<\/h3>\n\n\n\n
vim \/etc\/apache2\/conf-available\/cacti.conf<\/code><\/pre>\n\n\n\n
\nAlias \/cacti \/var\/www\/html\/cacti\n\n<Directory \/var\/www\/html\/cacti\/>\n <IfModule mod_authz_core.c>\n Require all granted\n <\/IfModule>\n<\/Directory>\n<\/code><\/pre>\n\n\n\n
apachectl configtest<\/code><\/pre>\n\n\n\n
Syntax OK<\/strong><\/code>, output, restart Apache. Otherwise fix any would be errors.<\/p>\n\n\n\n
systemctl restart apache2<\/code><\/pre>\n\n\n\n
ufw allow \"Apache Full\"<\/code><\/pre>\n\n\n\n
Finalize installation and Setup of Cacti on Ubuntu 20.04<\/h3>\n\n\n\n
Accessing Cacti Web Interface<\/h4>\n\n\n\n
http:\/\/server-IP\/cacti<\/strong><\/code> as per our setup.<\/p>\n\n\n\n
admin:admin<\/code><\/strong> for both username and password.<\/p>\n\n\n\n
<\/figure><\/a><\/div>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
Reference<\/h3>\n\n\n\n
Other Related Tutorials<\/h3>\n\n\n\n