Monday, June 20, 2011

How to Install and Configure Cacti


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. Required softwares to install Cacti.
You need to install the following software to install cacti.
a)      MySQL Server : Store cacti data
b)      NET-SNMP server – SNMP (Simple Network Management Protocol) is a protocol used for network management.
c)      PHP with net-snmp module – Access SNMP data using PHP.
d)     Apache / lighttpd / ngnix webserver : Web server to display graphs created with PHP and RRDTOOL.
Install the software
You can install the softwares  using yum command. Run the following:-
# 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
Setting up root password:-
# mysqladmin -u root password NEWPASSWORD
Create cacti MySQL database
# mysql -u root -p -e ‘create database cacti’
Create a user name cacti with a password your password, then enter
Login to mysql
# mysql -u root –p
mysql> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY ‘your password’;
mysql> FLUSH privileges;
mysql> ¥q
Intall snmpd
Type the following command to install net-snmpd
# yum install net-snmp-utils php-snmp net-snmp-libs
To configure snmpd, open the snmpd.conf configuration file.
# vi /etc/snmp/snm pd.conf
And modify the conafiguration file. As see below.
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 closed the configuration file and start the snmp service. Type the following.
# /etc/init.d/snmpd start
# chkconfig snmpd on
Install cacti
Update the repository:< o:p>
# 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 database string:-Open /var/www/cacti/include< br># config.php
Modify the following 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 = “your password”;
$database_port = “3306″;

Configure httpd for cacti.
Update allow from line, set to your LAN subnet to allow access to cacti:
Open /etc/httpd/conf.d/cacti.conf file
# vi /etc/httpd/conf.d/cacti.conf
Alias /cacti/ /var/www/cacti/

DirectoryIndex index.php
Options -Indexes
AllowOverride all
order deny,allow
allow from 172.16.0.0/16 #your network address
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc on
php_flag track_vars on
After changed start the httpd:-
# /etc/init.d/httpd  start
Setup cacti cronjob
Open /etc/cron.d/cacti file
# vi /etc/cron.d/cacti
Uncomment the line:
*/5 * * * *     cacti   /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1
Save and closed the file after uncomment.
Now cacti is ready, you can run the cacti type the following:-
Note:< /span> The default username and password for cacti is admin / admin.