Cacti is a free and open source web-based network monitoring and graphing tool designed as the PHP front-end application for the RRDtool. Cacti is a complete frontend to RRDTool that stores all of the necessary information to create graphs and populate them with data in a MySQL database. Cacti allow us to check the services at an interval of time and resulting in the graph format. It is used to get a graph data for the CPU and network bandwidth utilization and monitors the network traffic by polling a router or switch via SNMP protocol. You can easily monitor the performance of your server, network, router, switch, web application and other services like, Mysql, Apache, Mail server, and DNS using Cacti. Cacti provide a fast poller, advanced graph templating, multiple data acquisition methods, and user management features out of the box.
In this tutorial, we will be installing and configuring Cacti monitoring tool on an Alibaba Cloud Elastic Compute Service (ECS) Ubuntu 16.04 server.
First, Login to your Alibaba Cloud ECS Console. Create a new ECS instance, choosing Ubuntu 16.04 as the operating system with at least 2GB RAM. Connect to your ECS instance and log in as the root user.
Once you are logged into your Ubuntu 16.04 instance, run the following command to update your base system with the latest available packages.
apt-get update -y
Cacti run on the web server, written in PHP and uses MariaDB to store their data. So, you will need to install Apache, MariaDB and PHP to your server. You can install all of them by running the following command:
apt-get install -y apache2 mariadb-server mariadb-client php-mysql libapache2-mod-php7.0 -y
Next, you will also need to install some other required packages like, snmp, rrdtool and PHP modules to your server. You can install them by running the following command:
apt-get install php7.0-xml php7.0-ldap php7.0-mbstring php7.0-gd php7.0-gmp snmp php7.0-snmp rrdtool librrds-perl -y
By default, MariaDB installation is not secured. So, you will need to secure it first. You can secure it by running the mysql_secure_installation script:
Answer all the questions as shown below:
Enter current password for root (enter for none): Set root password? [Y/n]: N Remove anonymous users? [Y/n]: Y Disallow root login remotely? [Y/n]: Y Remove test database and access to it? [Y/n]: Y Reload privilege tables now? [Y/n]: Y
After securing MariaDB, log in to MariaDB console with the following command:
mysql -u root -p
Enter your root password when prompt, then create a database and user for Cacti:
MariaDB [(none)]> create database cactidb; MariaDB [(none)]> GRANT ALL ON cactidb.* TO cactiuser@localhost IDENTIFIED BY 'password';
Next, flush the privileges with the following command:
MariaDB [(none)]> flush privileges;
Finally, exit from the MariaDB console with the following command:
MariaDB [(none)]> exit;
Next, you will need to change some MariaDB variables settings for better performances. You can do this by editing /etc/mysql/mariadb.conf.d/50-server.cnf file:
Add the following lines under [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
Save and close the file. When you are finished. Then, change Timezone setting in php.ini file:
Make the following changes:
date.timezone = Asia/Kolkata
Save and close the file. Then, restart Apache and MariaDB service with the following command:
systemctl restart apache2 systemctl restart mysql
You can install Cacti using two ways, 1) Install Cacti from Ubuntu default repository and 2) Install Cacti from Source.
Here, we will install Cacti from Source. You can download the latest version of the Cacti from their official website using the following command:
Once the download is completed, extract the downloaded file and copy the extracted directory to the Apache web root directory with the following command:
tar -xvzf cacti-latest.tar.gz cp -r cacti-1.1.38 /var/www/html/cacti
Next, create a log file to store Cacti log and give proper permissions to the cacti directory with the following command:
touch /var/www/html/cacti/log/cacti.log chown -R www-data:www-data /var/www/html/cacti chmod -R 777 /var/www/html/cacti
Next, you will need to import cacti database tables from the cacti.sql file. You can do this with the following command:
cd /var/www/html/cacti mysql -u root -p cactidb < /opt/cacti/cacti.sql
Next, edit config.php file and provides Cacti database credentials:
Make the following changes:
$database_type = "mysql"; $database_default = "cactidb"; $database_hostname = "localhost"; $database_username = "cactiuser"; $database_password = "password"; $database_port = "3306"; $database_ssl = false;
Save and close the file, when you are finished.
Next, you will need to create an Apache Virtual host file for Cacti. You can do this by creating the following file:
Add the following lines:
<VirtualHost *:80> Alias /cacti /var/www/html/cacti <Directory /var/www/html/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> </VirtualHost>
Save and close the file. Then, enable Apache virtual host file with the following command:
Finally, restart Apache service to apply all the changes:
systemctl restart apache2
Next, you will need to create a cronjob for Cacti poller service that poll every five minutes.
Add the following line:
*/5 * * * * www-data php /var/www/html/cacti/poller.php > /dev/null 2>&1
Save and close the file. Then, restart cron service with the following command:
systemctl restart cron
Cacti is now installed. It's time to set up it through a web browser.
Open your web browser and type the URL http://your-server-ip/cacti. You will be redirected to the Cacti license agreement page:
Now, accept the license agreement and click on Begin button. You will be redirected to the Cacti pre-installation check page:
Make sure all the required packages are installed. Then, click on the Next button. You should see the following page:
Here, choose the installation type and click on the Next button. You should see the following page:
Make sure all the required values are correct. Then, click on the Next button. You should see the following page:
Here, select the Templates that you wish to use after the installation. Then, click on the Finish button. You will be redirected to the Cacti login page:
Now, provide default username/password as admin/admin. Then, click on the Login button. You will be redirected to the Change password page:
Here, change your current password and click on the Save button. You will be redirected to the Cacti default dashboard as shown on the following page:
Congratulations! You have successfully installed Cacti monitoring tool on Ubuntu 16.04 server.
Alibaba Clouder - February 13, 2018
Alibaba Clouder - April 23, 2019
Alibaba Clouder - May 7, 2019
Alibaba Clouder - June 4, 2019
Alibaba Clouder - June 11, 2018
Alibaba Clouder - February 13, 2019
Build business monitoring capabilities with real time response based on frontend monitoring, application monitoring, and custom business monitoring capabilitiesLearn More
An online computing service that offers elastic and secure virtual cloud servers to cater all your cloud hosting needs.Learn More
Simplify the Operations and Management (O&M) of your computing resourcesLearn More
Secure your cloud resources with Resource Access Management to define fine-grained access permissions for users and groupsLearn More
More Posts by Alibaba Clouder