How to install CACTI ON CentOS / Red Hat / Fedora Linux

Learn | Teach Open Source Technologies

How to install CACTI ON CentOS / Red Hat / Fedora Linux

CACTI INSTALLATION ON CENTOS

Install the required packages on your server machines, to install these packages you need to login as root

 # 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

Configure MySQL server

First, set root password:
 # mysqladmin -u root password NEWPASSWORD

Create cacti MySQL database

Create a database called cacti, enter:

# mysql -u root -p -e 'create database cacti'
 Create a user called cacti with a password called zYn95ph43zYtq, enter:

# mysql -u root -p
mysql> GRANTALLON cacti.* TO cacti@localhost IDENTIFIEDBY 'zYn95ph43zYtq';
mysql> FLUSH privileges;
mysql> \q

Install snmpd

Type the following command to install net-snmpd

# yum install net-snmp-utils php-snmp net-snmp-libs
Configure snmpd, open /etc/snmp/snmpd.conf
 # vi /etc/snmp/snmpd.conf
 Append / modify it as follows (see snmpd.conf man page for details):
com2sec local     localhost           public
group MyRWGroup v1         local
group MyRWGroup v2c        local
group MyRWGroup usm        local
view all    included  .1                               80
access MyRWGroup ""      any       noauth    exact  all    all    none
syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root  (configure /etc/snmp/snmp.local.conf)
pass .1.3.6.1.4.1.4413.4.1 /usr/bin/ucd5820stat

Save and close the file. Turn on snmpd service:

# /etc/init.d/snmpd start
 # chkconfig snmpd on

Make sure you are getting information from snmpd:

# snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
 Sample ouptut:
IP-MIB::ipAdEntIfIndex.10.10.29.68 = INTEGER: 2
IP-MIB::ipAdEntIfIndex.67.yy.zz.eee = INTEGER: 3
IP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1

Install cacti

First, make sure EPEL repo is enabled. Type the following command to install cacti:

# yum install cacti
Install cacti tables
Type the following command to find out cacti.sql path:
# rpm -ql cacti | grep cacti.sql
 Sample output:
/usr/share/doc/cacti-0.8.7d/cacti.sql

Type the following command to install cacti tables (you need to type the cacti user password):

# mysql -u cacti -p cacti < /usr/share/doc/cacti-0.8.7d/cacti.sql

Configure cacti

Open /etc/cacti/db.php file, enter:
# vi /etc/cacti/db.php
Make changes as follows:
/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "zeeshan";
$database_port = "3306";
wq!

Save and close the file.

Configure httpd

Open /etc/httpd/conf.d/cacti.conf file, enter:

# vi /etc/httpd/conf.d/cacti.conf
 You need to update allow from line. Either set to ALL or your LAN subnet to allow access to cacti:
#
# Cacti: An rrd based graphing tool
#
Alias /cacti    /usr/share/cacti
<Directory /usr/share/cacti/>
Order Deny,Allow
Deny from all
Allow from 10.0.0.0/8
</Directory>

Another option is create /usr/share/cacti/.htaccess file and password protect the directory. Finally, restart httpd:
 # service httpd restart

Setup cacti cronjob

Open /etc/cron.d/cacti file, enter:

# vi /etc/cron.d/cacti
 Uncomment the line:
*/5 * * * *     cacti   /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1
Save and close the file.

Run cacti installer

Now cacti is ready to install. Fire a web browser and type the url:

http://your.example.com/cacti/
 OR
 http://your.server.ip.address/cacti/