Cacti is an open source Network monitoring tool, it’s 100% FREE for everyone in this world. Cacti is a complete network graphing solution designed with RRDTool’s data storage and graphing functionality. Using Cacti you can easily monitor the performance of your computers, networks, servers, router, switch, services (apache, mysql, dns, harddisk, mail server), SANs, applications, weather measurements, etc… Cacti using snmp to collect the data from other devices. Cacti announced the latest release of Cacti 0.8.8g version on February 21, 2016. Also read about Cacti installation on Ubuntu, Debian & Mint Systems. Alternatively you can install other network monitoring tools such as Zabbix, Nagios, Monitorix, Munin & Icinga2.
1) Prerequisites for Cacti
Make a note use dnf instead of yum on Fedora 22 & later systems.
# Prerequisites for Debian based systems # $ sudo apt-get install rrdtool snmp snmpd php5-gd php5-snmp-y # Prerequisites for RPM based systems # # yum install php-gd rrdtool php-snmp net-snmp-utils net-snmp-libs httpd-devel php-mysql php-pear php-common php-devel php php-mbstring php-cli # Start SNMP Deamon # # service snmpd start # [For SysVinit Systems] # systemctl start snmpd.service # [For systemd Systems]
2) Create user for Cacti
Create a user for cacti and make a note we can use it later.
# useradd cacti
3) Create Database for Cacti
Create MySQL database, database username and assign the user to cacti database and import cacti pre defined tables.
# mysql -u root -p MariaDB [(none)]> create database cacti; MariaDB [(none)]> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY '2daygeek'; MariaDB [(none)]> FLUSH privileges; MariaDB [(none)]> quit;
4) Download & Extract Cacti archive
Visit Cacti website and download latest version of cacti. When we writing this article we got cacti 0.8.8f version. Just download and extract it to /var/www/html/.
# wget http://www.cacti.net/downloads/cacti-0.8.8f.tar.gz # tar -xvzf cacti-0.8.8f.tar.gz # cd /opt/cacti-0.8.8f # mv * /var/www/html/cacti # rm -Rf cacti-0.8.8f.tar.gz
Now import Cacti Tables to Cacti Database, which is available at /var/www/html/cacti/cacti.sql file then import it.
# Import cacti.sql file # # mysql -u cacti -p cacti < /var/www/html/cacti/cacti.sql # Modify config.php file # # nano /var/www/html/cacti/include/config.php $database_type = "mysql"; $database_default = "cacti"; $database_hostname = "localhost"; $database_username = "cacti"; $database_password = "cacti-password-here"; $database_port = "3306"; $database_ssl = false;
4) Set Permission to cacti
Change the user and group permission of cacti web directory to apache user based on your distribution.
# For Debian based systems # chown -R www-data:www-data /var/www/html/cacti/ # For RPM based systems # chown -R apache:apache /var/www/html/cacti/ # Change ownership of rra and log directory in cacti web directory with system user which we created on initial stage (I have created cacti as a system user) # chown -R cacti /var/www/html/cacti/rra/ /var/www/html/cacti/log/
Setup Cron for Cacti : Open the file /etc/cron.d/cacti and uncomment the below line. The poller.php file will collects data of known host every 5 mins which is used by Cacti application to generate graphs. For manual installation, add the below line into crontab file.
# crontab -e */5 * * * * /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1
Restart Apache Web Server
# [For SysVinit Systems] # service apache2 restart # [For DEB Systems] # service httpd restart # [For RPM Systems] # [For Systemd Systems] # systemctl restart apache2.service # [For DEB Systems] # systemctl restart httpd.service # [For RPM Systems]
5) Setup Cacti
Follow the below instructions to setup the Cacti. Navigate your browser to http://localhost/cacti or http://IP-Address/cacti or http://Domain-Name/cacti and hit Next.
Choose the installation type, By default it chooses New Install, then hit Next.
Check below Whether everything is GREEN, If so there is no error in your installation, then hit Finish.
You will be re-directed to admin page, Here you need to enter admin username and its password. admin is default username and password for cacti.
For first time, you need to modify the default password.
Cacti Home page.
Stay tune with us will cover in next article, how to add Linux & windows hosts into cacti.