Cacti Network Monitoring Tool


Cacti is a complete network graphing solution designed to harness the power of RRDTool's data storage and graphing functionality. Cacti provides a fast poller, advanced graph template, multiple data acquisition methods, and user management features

A common usage is to monitor network traffic by polling a network switch or router interface via
Simple Network Management Protocol (SNMP).

RRDtool​ (acronym for ​ r​ound-​ r​obin ​ d​database ​ tool​ ) aims to handle time-series data like network
bandwidth, temperatures, CPU load, etc. The data are stored in a circular buffer based database,
thus the system storage footprint remains constant over time. Note that this is distinct from the
computer science concept of round-robin scheduling.

Simple Network Management Protocol (SNMP) is a popular protocol for network management. It is used for collecting information from, and configuring, network devices, such as servers, printers, hubs, switches, and routers on an Internet Protocol (IP) network. SNMP agent software that works with third-party SNMP management software to monitor the status of managed devices and applications.







Cacti Installation and Configuration in CentOS 7:

1. Install dependency:-
a) MySQL
b) PHP
c) SNMP
d) SMTP
yum install mysql-server mysql php-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli php-snmp php-pear-Net-SMTP php-mysql httpd net-snmp-utils php-snmp net-snmp-libs -y


Install Apache:-
yum install httpd httpd-devel -y
httpd -v

Once installed all dependency packages start the below services 

Start the service:
systemctl start httpd
systemctl start snmpd
systemctl start mysql

systemctl enable mysql
systemctl enable httpd
systemctl enable snmpd


2. Configure DB for cacti using MySQL:-
You can try any one of method mentioned below, Here I have tried second method.

Create a Separate database for cacti and also need to create user for cacti database and grant all privilege to cacti user. 
At last after granting privilege we need to flush the privileges. 

mysql -u root -p
CREATE DATABASE cacti;
CRETAE USER cacti;
GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'admin';
FLUSH privileges;

or

mysql -u root -p -e 'create database cacti'
mysql -u root -p
create user cacti;
GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'admin';
FLUSH privileges;




4. Configure SNMP:-
vim /etc/snmp/snmpd.conf

Uncomment and Change the community name to any except public
com2sec local localhost linux
com2sec mynetwork 10.11.0.0/24 linux

Uncomment and change line No 78,79
group MyRWGroup v2c     local
group MyROGroup v2c     mynetwork


Note: Here My Community name is linux

Uncomment the line No: 85
view all    included  .1                   80



Uncomment and change line No 93,94
access MyROGroup "" v2c   noauth   exact   all   none   none
access MyRWGroup "" v2c   noauth   exact   all   all      all


systemctl start snmpd 
systemctl enable snmpd

snmpwalk -v 1 -c linux localhost



5. Install Cacti:-
yum install epel-release -y
yum install cacti -y



6. Import cacti table into cacti database:-
rpm -ql cacti|grep cacti.sql  -> Downloading SQL file for cacti table via rpm
mysql -u cactiuser -p cacti < /usr/share/doc/cacti-0.8.8h/cacti.sql    -> Going to dump the downloaded file into MySQL cacti database


7. Configure cacti db file:-
cp -r /etc/cacti/db.php /etc/cacti/db.php-ori  -> Make a copy of cacti DB file for safety
vim /etc/cacti/db.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cactipass";


Cacti DB file we need to specify cacti user name and password. We have already created Cacti user / password in MySQL ref step 2. So we have to specify the same one on this file. 

8. Add http service in firewall:-
firewall-cmd --permanent --add-service=http
firewall-cmd --reload



If firewalld service is running, you need to add service or running port of apache in firewalld to access.


9. Configure Cacti:-
 vim /etc/httpd/conf.d/

Alias /cacti    /usr/share/cacti

<Directory /usr/share/cacti/>
<IfModule mod_authz_core.c>
# httpd 2.4
Require host localhost
                Require ip 10.0.0.0/8
</IfModule>
<IfModule !mod_authz_core.c>
# httpd 2.2
                 Order deny,allow
                 deny from all
                 allow from 10.0.0.0/8
</IfModule>
</Directory>


10. Crontab entry:-
*/5 * * * * cacti /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1


13. Access cacti via web URL:
http://10.11.12.40/cacti








Previous
Next Post »