Install Cacti on a Centos 6.x Virtual Host

posted in: Technical | 0

Installation process starts by installing the following packages:

yum install httpd php php-mysql php-snmp mysql mysql-server net-snmp rrdtool net-snmp-utils
yum install php-xml php-session php-sockets php-ldap php-gd

Next make sure that all of the installed package are up and running by issuing the following commands:

chkconfig httpd on
chkconfig mysqld on
chkconfig snmpd on


service httpd start
service snmpd start
service mysqld start

Create a database for Cacti:

mysql -u root -p
create database cacti;
GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactiuserpassword';
flush privileges;

Virtual host setting:

mkdir -p /var/www/cacti.example.com/public_html
cd /var/www/cacti.example.com/


wget http://www.cacti.net/downloads/cacti-0.8.8c.zip
unzip cacti-0.8.8c.zip


mv cacti-0.8.8c public_html/
chown -R cactiuser:apache public_html/

Import cacti default database:

cd /var/www/cactifolder/public_html
mysql -u root -p cacti < cacti.sql

Adding user for cacti:

useradd -d /var/www/cactifolder/public_html -s /sbin/nologin cactiuser

Edit include/config.php to suit the needs:


$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "yourcactipassword";
$database_port = "3306";
$database_ssl = false;
#
$url_path = "/";

Edit the httpd.conf to acomodate new virtual host for cacti web access:

nano /etc/httpd/conf/httpd.conf


<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/cacti.example.com/public_html
ServerName cacti.example.com
ServerAlias www.cacti.example.com
ErrorLog /var/www/cacti.example.com/error.log
CustomLog /var/www/cacti.example.com/access.log combined
#ErrorDocument 403 /error403.php
#ErrorDocument 404 /error404.php
#ErrorDocument 500 /error500.php
</VirtualHost>

Adding cacti poller schedule to /etc/crontab:

*/5 * * * * cactiuser php /var/www/cacti.example.com/public_html/poller.php > /dev/null 2>&1

Go to cacti web access via http://cacti.example.com and login with the following information:
username: admin
password: admin (default password)

Change cacti default password:
Go to “Console -> System Utilities” and click on “Rebuild Poller Cache” after the first login!

Adding Mikrotik template for a new installed cacti:

Download Mikrotik Cacti template (update 02/10/2009)

wget http://routing.explode.gr/system/files/mikrotik-20090210.zip
unzip mikrotik-20090210.zip

Copy each file to appropriate location as follows:

zipdir/scripts/mikrotik_wireless_interfaces.php -> cacti-web-dir/scripts/mikrotik_wireless_interfaces.php
zipdir/scripts/mikrotik_ppp_connections.php -> cacti-web-dir/scripts/mikrotik_ppp_connections.php
zipdir/resources/script_server/mikrotik_wireless_interfaces.xml -> cacti-web-dir/resource/script_server/mikrotik_wireless_interfaces.xml
zipdir/resources/snmp_queries/mikrotik_queue_simple.xml -> cacti-web-dir/resource/snmp_queries/mikrotik_queue_simple.xml
zipdir/resources/snmp_queries/mikrotik_queue_tree.xml -> cacti-web-dir/resource/snmp_queries/mikrotik_queue_tree.xml
zipdir/resources/snmp_queries/mikrotik_wireless_client.xml -> cacti-web-dir/resource/snmp_queries/mikrotik_wireless_client.xml

References:

http://blog.network-outsourcing.de/cacti-howtos/cacti/installing-cacti/
http://www.itzgeek.com/how-tos/linux/centos-how-tos/monitor-network-using-cacti-with-centos-6-rhel-6.html