Cacti is a complete frontend to RRDTool, it stores all of the necessary information to create graphs and populate them with data in a MySQL database. The 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. Mostly, Cacti user SNMP to query and gathering for the information about the network device's resources. In this post, we demonstrate how to install Cacti on Debian 10.
Modify Repository
For Debain 10 Buster
Update our system
Install Apache2 and PHP module
Change PHP setting
To verify the current time zone on our system ls -l /etc/localtime.
AND
Install SNMP and RRDTool
Install MariaDB
Customize MariaDB setting to get better performance. Place the following lines under [mysqld] section.
Restart MariaDB service
Create a database and database user for Cacti. Login into our database.
Import the timezone table into default databases.
Grant permission for cactiuser on the default database. Login into our database.
Install Cacti
There are two ways to install Cacti:
Method #1 Install Cacti from the repository
We can install Cacti from the repository of Debian with apt -y install cacti. The latest stable Cacti version will be installed.
Choose web service for Cacti, we use apache2 as web service, so press Tab to select OK.
Cacti ask for database configuration if we choose Yes, Cacti automatically configuration database for us. We want to configure a database by our hand so choose No.
Import database into MariaDB.
Configure username, password and database name for Cacti.
Change ownership on Cacti's directories to apache user (www-data)
Cron job
Method #2 Install Cacti Manually
When we install Cacti from the repository based on OS, the Cacti latest stable version in the repository will be installed. Sometimes we want to install Cacti by a specific version based on our requirement. So, we can manually install Cacti from the source. First, download the Cacti source from the Cacti site https://www.cacti.net/downloads. Select which version we want to install, in this guide we will install cacti-1.2.2.
Download the Cacti source.
Extract the Cacti source.
Move Cacti to DocumentRoot of apache.
Change ownership to apache user (www-data). Move Cacti to DocumentRoot of apache.
Import Cacti database
Configure username, password, and database name for Cacti.
Create a Cron job
Cacti need to run its poller regularly, so we need to schedule it with cron job.
Setup Cacti
Open favorite web browser and type http://server_ip/cacti . Default username and password (admin: admin) and change a new password.
Check the box Accept GPL License Agreement and Begin.
This step the Cacti validates the PHP and MySQL setting, if there is any recommendation will be shown here. Next.
Keep the default settings. Next.
Directories permission, Cacti check the directories permission all directories should be granted to www-data apache user. Next.
Critical Binary that Cacti will use to function its operation properly. If any binary missing Cacti will show here.
Default Profile. Next.
This is the default template that will be created with the Cacti installation. Next.
This is the warning from our database setting. we can keep it default. Next.
Confirm Installation and Install.
We are almost done here, Get Started to finish our installation.
We are done for Cacti Installation.
Conclusion
Cacti is a web-based open-source monitoring system, that provides the graphing solution by RRDTool. We can use Cacti to monitor network traffic, system resource like CPU, RAM, HardDisk, and so on. I hope you all be able to understand this post well. If you don't understand any point or have any problem, recommendation, the suggestion doesn't hesitate to tell us, we will try our best to help. You may also like Related Posted:
READ: Monitor Linux and Windows
READ: How to create Graph Tree on Cacti
READ: How to Install Plugin on Cacti
READ: Notification on Cacti
Modify Repository
nano /etc/apt/sources.list
For Debain 10 Buster
deb http://deb.debian.org/debian/ buster main
deb http://security.debian.org/debian-security buster/updates main
# buster-updates, previously known as 'volatile'
deb http://deb.debian.org/debian/ buster-updates main
deb http://security.debian.org/debian-security buster/updates main
# buster-updates, previously known as 'volatile'
deb http://deb.debian.org/debian/ buster-updates main
Update our system
apt -y update
Install Apache2 and PHP module
apt install -y vim apache2 libapache2-mod-php php-xml php-ldap php-mbstring php-gd php-gmp php-mysql
Change PHP setting
To verify the current time zone on our system ls -l /etc/localtime.
vim /etc/php/7.3/apache2/php.ini
AND
vim /etc/php/7.3/cli/php.ini
date.timezone = Asia/Phnom_Penh
memory_limit = 512M
max_execution_time = 60
memory_limit = 512M
max_execution_time = 60
Install SNMP and RRDTool
apt install -y snmpd php-snmp rrdtool librrds-perl
Install MariaDB
apt install -y mariadb-server mariadb-client
Customize MariaDB setting to get better performance. Place the following lines under [mysqld] section.
vim /etc/mysql/mariadb.conf.d/50-server.cnf
collation-server=utf8mb4_unicode_ci
character-set-server=utf8mb4
max_heap_table_size = 128M
tmp_table_size = 64M
join_buffer_size = 64M
innodb_file_format = Barracuda
innodb_large_prefix = 1
innodb_buffer_pool_size = 1GB
innodb_buffer_pool_instances = 10
innodb_flush_log_at_timeout = 3
innodb_read_io_threads = 32
innodb_write_io_threads = 16
innodb_io_capacity = 5000
innodb_io_capacity_max = 10000
character-set-server=utf8mb4
max_heap_table_size = 128M
tmp_table_size = 64M
join_buffer_size = 64M
innodb_file_format = Barracuda
innodb_large_prefix = 1
innodb_buffer_pool_size = 1GB
innodb_buffer_pool_instances = 10
innodb_flush_log_at_timeout = 3
innodb_read_io_threads = 32
innodb_write_io_threads = 16
innodb_io_capacity = 5000
innodb_io_capacity_max = 10000
Restart MariaDB service
systemctl restart mariadb
Create a database and database user for Cacti. Login into our database.
mysql -u root -p
create database cacti;
GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactipassword';
flush privileges;
exit;
GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactipassword';
flush privileges;
exit;
Import the timezone table into default databases.
mysql -u root -p mysql < /usr/share/mysql/mysql_test_data_timezone.sql
Grant permission for cactiuser on the default database. Login into our database.
mysql -u root -p
GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost;
flush privileges;
exit;
flush privileges;
exit;
Install Cacti
There are two ways to install Cacti:
Method #1 Install Cacti from the repository
We can install Cacti from the repository of Debian with apt -y install cacti. The latest stable Cacti version will be installed.
apt install -y cacti
Choose web service for Cacti, we use apache2 as web service, so press Tab to select OK.
Cacti ask for database configuration if we choose Yes, Cacti automatically configuration database for us. We want to configure a database by our hand so choose No.
Import database into MariaDB.
mysql -u root -p cacti < /usr/share/doc/cacti/cacti.sql
Configure username, password and database name for Cacti.
vim /usr/share/cacti/site/include/config.php
$database_type = 'mysql';
$database_default = 'cacti';
$database_hostname = 'localhost';
$database_username = 'cactiuser';
$database_password = 'cactipassword';
$database_port = '3306';
$database_ssl = false;
$database_ssl_key = '';
$database_ssl_cert = '';
$database_ssl_ca = '';
$database_default = 'cacti';
$database_hostname = 'localhost';
$database_username = 'cactiuser';
$database_password = 'cactipassword';
$database_port = '3306';
$database_ssl = false;
$database_ssl_key = '';
$database_ssl_cert = '';
$database_ssl_ca = '';
Change ownership on Cacti's directories to apache user (www-data)
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/
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/
Cron job
/etc/cron.d/cacti
MAILTO=root
*/5 * * * * www-data php /usr/share/cacti/site/poller.php 2>&1 >/dev/null | if [ -f /usr/bin/ts ] ; then ts ; else tee ; fi >> /var/log/cacti/poller-error.log
*/5 * * * * www-data php /usr/share/cacti/site/poller.php 2>&1 >/dev/null | if [ -f /usr/bin/ts ] ; then ts ; else tee ; fi >> /var/log/cacti/poller-error.log
Method #2 Install Cacti Manually
When we install Cacti from the repository based on OS, the Cacti latest stable version in the repository will be installed. Sometimes we want to install Cacti by a specific version based on our requirement. So, we can manually install Cacti from the source. First, download the Cacti source from the Cacti site https://www.cacti.net/downloads. Select which version we want to install, in this guide we will install cacti-1.2.2.
Download the Cacti source.
wget https://cacti.net/downloads/cacti-1.2.2.zip
Extract the Cacti source.
unzip cacti-1.2.2.zip
Move Cacti to DocumentRoot of apache.
mv cacti-1.2.2 /var/www/html/cacti
Change ownership to apache user (www-data). Move Cacti to DocumentRoot of apache.
chown -R www-data.www-data /var/www/html/cacti
Import Cacti database
mysql -u root -p cacti < /var/www/html/cacti/cacti.sql
Configure username, password, and database name for Cacti.
vim /var/www/html/cacti/include/config.php
$database_type = 'mysql';
$database_default = 'cacti';
$database_hostname = 'localhost';
$database_username = 'cactiuser';
$database_password = 'cactipassword';
$database_port = '3306';
$database_ssl = false;
$database_ssl_key = '';
$database_ssl_cert = '';
$database_ssl_ca = '';
$database_default = 'cacti';
$database_hostname = 'localhost';
$database_username = 'cactiuser';
$database_password = 'cactipassword';
$database_port = '3306';
$database_ssl = false;
$database_ssl_key = '';
$database_ssl_cert = '';
$database_ssl_ca = '';
Create a Cron job
Cacti need to run its poller regularly, so we need to schedule it with cron job.
echo '*/5 * * * * www-data /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1' >/etc/cron.d/cacti
Setup Cacti
Open favorite web browser and type http://server_ip/cacti . Default username and password (admin: admin) and change a new password.
Check the box Accept GPL License Agreement and Begin.
This step the Cacti validates the PHP and MySQL setting, if there is any recommendation will be shown here. Next.
Keep the default settings. Next.
Directories permission, Cacti check the directories permission all directories should be granted to www-data apache user. Next.
Critical Binary that Cacti will use to function its operation properly. If any binary missing Cacti will show here.
Default Profile. Next.
This is the default template that will be created with the Cacti installation. Next.
This is the warning from our database setting. we can keep it default. Next.
Confirm Installation and Install.
We are almost done here, Get Started to finish our installation.
We are done for Cacti Installation.
Conclusion
Cacti is a web-based open-source monitoring system, that provides the graphing solution by RRDTool. We can use Cacti to monitor network traffic, system resource like CPU, RAM, HardDisk, and so on. I hope you all be able to understand this post well. If you don't understand any point or have any problem, recommendation, the suggestion doesn't hesitate to tell us, we will try our best to help. You may also like Related Posted:
READ: Monitor Linux and Windows
READ: How to create Graph Tree on Cacti
READ: How to Install Plugin on Cacti
READ: Notification on Cacti
No comments:
Post a Comment