Cacti is very well known name in monitoring system. It is RRD tool based, gather the information by using external script/command and feed the data into RDBMS database like MySQL/MariaDB. Cacti frontend is basically written in PHP. We can use the SNMP to gather the information and feed into Cacti database . You can view the data in graphs managed by RRD tool in Cacti server.
Basic requirement to install cacti
- Webserver : HTTPD (In this practical we are using Apache2)
- php : Because Cacti has PHP based frontend.
- php-mysql : PHP extension which will help PHP code to connect and manage the queries in MySQL Database server.
- php-snmp : PHP extension to help php code to manage remote devices via the SNMP ( Simple Network Management Protocol ).
-
mysql : This is mysql client. To use the MySQL client to manage the MySQL server database use the command
mysql
. For eg.mysql -u root -p
- mysql-server : This is RDBMS based MySQL Server .
- net-snmp : Net-SNMP is a suite of software for using and deploying the SNMP protocol (v1, v2c and v3 and the AgentX subagent protocol).
Description of Cacti Server in our lab
Given below is description of our Cacti server in our lab.
Operating System : Ubuntu 14.04 LTS Server
Arch : x86_64
Database Server : MySQL Server 5.6
Web Server : Apache2
IP Address : 192.168.122.116
Install Cacti Pre-Requisite Requirement
Now install cacti pre-requisite requirement.
In ubuntu let’s first update the apt repo.
sudo apt-get update
Installing Apache, PHP, PHP extension, SNMP :
sudo apt-get install apache2 php5 php5-mysql php5-snmp snmp php5-gd
Installing RRD-Tool :
sudo apt-get install rrdtool
Install MySQL Server 5.6 : While installing mysql server, on screen you will see to set mysql root password. Hence, set the desired strong password.
sudo apt-get install mysql-server-5.6
Create system user for cacti
Create one system user for cacti. Later in this post you will know where we will use it.
sudo useradd cactiuser
Workaround in MySQL database server
In this section, we will create database and user for Cacti. We have granted all privileges to database user called cactiuser to database cactidb (see in queries given below) .
First login into mysql server, use the mysql root password which you have set while installing mysql server.
mysql -u root -p
Follow the given below queries in mysql database. Replace Password with strong password you want to set for cactiuser (database user)
mysql> create database cactidb; mysql> CREATE USER 'cactiuser'@'localhost' IDENTIFIED BY 'Password'; mysql> GRANT ALL ON cactidb.* TO 'cactiuser'@'localhost'; mysql> flush privileges; mysql> exit
Download and extract the Cacti tar ball
Download and extract the Cacti tar ball. We will copy the extracted out cacti source and rename as cacti in /var/www/html directory.
wget http://www.cacti.net/downloads/cacti-0.8.8d.tar.gz tar -xvzf cacti-0.8.8d.tar.gz sudo cp -prvf cacti-0.8.8d /var/www/html/cacti
Restore cacti database from dump file
Use the already available cacti.sql dump file to restore into Cacti database.
mysql -u root -p cactidb < /var/www/html/cacti/cacti.sql
Settings for Cacti in config.php
Edit the cacti include/config.php file.
sudo vi /var/www/html/cacti/include/config.php
Do the follow settings in config.php and set the correct values.
$database_type = "mysql"; $database_default = "cactidb"; $database_hostname = "localhost"; $database_username = "cactiuser"; $database_password = "Password"; $database_port = "3306"; $database_ssl = false; $url_path = "/cacti/"; $cacti_session_name = "Cacti";
Set owner/group to cacti web directory
Change the Ownership and group of cacti web directory to apache user that is www-data .
chown -R www-data:www-data /var/www/html/cacti/
Change ownership of rra and log directory in cacti web directory with cactiuser (it is system user which we created in beginning of this post).
chown -R cactiuser /var/www/html/cacti/rra/ /var/www/html/cacti/log/
Set crontab for poller script
Edit /etc/crontab file
vi /etc/crontab
Add the following given line at end of crontab. The cron will be run by user cactiuser in every 5 minutes,daily.
## Cacti */5 * * * * cactiuser php /var/www/html/cacti/poller.php > /dev/null 2>&1
Restart Web server
After completing all steps, restart the Apache.
sudo service apache2 restart
Follow the installation in Web browser interface
Now rest of installation process will be completed through web browser interface.
Open the web browser and type the IP address of cacti server suffix by /cacti
.
For eg. our cacti server ip address is 192.168.122.116 , hence in web browser we will type http://192.168.122.116/cacti
Figure 1: You will get the "Cacti Installation Guide" on screen. Click on 'Next' button.
Figure 2: In next screen, you will get drop down button. Because this fresh installation select 'New Install' and click 'Next' button .
Figure 3: In next screen, you will see many information which mainly includes path of RRDtool, php, snmpwalk, snmpget, snmpbulkwalk, snmpgetnext, cacti log path, RRD tool version and SNMP version. Click 'Finish' button.
(in case, any dependency is not found you can not finish the installation)
Figure 4: In next screen, you will get login form on screen.
By default username/password is admin/admin . Use the username and password in login form.
Figure 5:
In next screen, it will force you to set the new password for admin .
Now you are able to login into Cacti server with new password of adminuser and can set the monitoring.
The given below screenshots are after admin login into Cacti dashboard.
Some graphs of localhost. (Just wait for 5 minutes, you will see the graphs)
Please help me, I have this error in browser:
FATAL: Cannot connect to MySQL server on ‘localhost’. Please make sure you have specified a valid MySQL database name in ‘include/config.php’
My config:
/* make sure these values refect your actual database/host/user/password */
$database_type = “mysql”;
$database_default = “cactidb”;
$database_hostname = “localhost”;
$database_username = “cactiuser”;
$database_password = “Passw0rd”;
$database_port = “3306”;
$database_ssl = false;
/*
Edit this to point to the default URL of your Cacti install
ex: if your cacti install as at http://serverip/cacti/ this
would be set to /cacti/
*/
$url_path = “/cacti/”;
/* Default session name – Session name must contain alpha characters */
$cacti_session_name = “Cacti”;
Hi Christian,
Check by directly connecting from terminal.
If you are not able to login with this user then login with root and reset the password of database user which you have created.
Regards
Sharad
that UI really needs a refresh.looks like a 1999 website
Hello
I am a newbie in Linux. I am now testing on Ubuntu 14.04 and I install cacti. Now I have trouble on how can I error or log message to my email and to my GSM phone to send notification message. How do I these case. Pls help me.