Network Monitoring
–>Need
*Apache : A Web server to display network graphs created by PHP and RRDTool.
*MySQL : A Database server to store cacti information.
*PHP : A script module to create graphs using RRDTool.
*PHP-SNMP : A PHP extension for SNMP to access data.
*NET-SNMP : A SNMP (Simple Network Management Protocol) is used to manage network.
*RRDTool : A database tool to manage and retrieve time series data like CPU load, Network Bandwidth etc.
Install MySQL
1 2 3 |
# yum install mysql mysql-server |
Install PHP
1 2 3 |
# yum install php-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli php-mysql |
Install PHP-SNMP
1 2 3 |
# yum install php-snmp |
Install NET-SNMP
1 2 3 |
# yum install net-snmp-utils p net-snmp-libs php-pear-Net-SMTP |
Install RRDTool
1 2 3 |
# yum install rrdtool |
Staring Apache, MySQL and SNMP Services
Once you’ve installed all the required software’s for Cacti installation, lets start them one-by-one using following commands.
Starting Apache
1 2 3 4 5 |
# /etc/init.d/httpd start OR # service httpd start |
Starting MySQL
1 2 3 4 5 |
# /etc/init.d/mysqld start OR # service mysqld start |
Starting SNMP
1 2 3 4 5 |
# /etc/init.d/snmpd start OR # service snmpd start |
Configure Start-up Links
Configuring Apache, MySQL and SNMP Services to start on boot.
1 2 3 4 5 |
# /sbin/chkconfig --levels 345 httpd on # /sbin/chkconfig --levels 345 mysqld on # /sbin/chkconfig --levels 345 snmpd on |
Install Cacti on RHEL / CentOS / Fedora
Here, you need to install and enable EPEL Repository. Once you’ve enabled repository, type the following command to install Cacti application.
1 2 3 |
# yum install cacti |
Sample Output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
Loaded plugins: fastestmirror, refresh-packagekit Resolving Dependencies --> Running transaction check ---> Package cacti.noarch 0:0.8.8a-2.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: cacti noarch 0.8.8a-2.el6 epel 2.0 M Transaction Summary ================================================================================ Install 1 Package(s) Total download size: 2.0 M Installed size: 5.4 M Is this ok [y/N]: y Downloading Packages: cacti-0.8.8a-2.el6.noarch.rpm | 2.0 MB 00:40 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : cacti-0.8.8a-2.el6.noarch 1/1 Verifying : cacti-0.8.8a-2.el6.noarch 1/1 Installed: cacti.noarch 0:0.8.8a-2.el6 Complete! |
Configuring MySQL Server for Cacti Installation
We need to configure MySQL for Cacti, to do this we need to set password for our newly installed MySQL server and then we will create Cacti database with user Cacti. If you’reMySQL is already password protected, then don’t need to set it again.
Set MySQL Password
To set new password for MySQL server, use the following command. (Note : This is for new MySQL installation only).
1 2 3 |
# mysqladmin -u root password <strong>YOUR-PASSWORD-HERE</strong> |
Create MySQL Cacti Database
Login into MySQL server with newly created password and create Cacti database with userCacti and set the password for it.
1 2 3 4 5 6 7 |
# mysql -u root -p mysql> create database <strong>cacti</strong>; mysql> GRANT ALL ON cacti.* TO <strong>cacti</strong>@localhost IDENTIFIED BY '<strong>your-password-here</strong>'; mysql> FLUSH privileges; mysql> quit; |
Install Cacti Tables to MySQL
Find out the database file path using RPM command, to install cacti tables into newly createdCacti database, use the following command.
1 2 3 |
# rpm -ql cacti | grep cacti.sql |
Sample Output:
/var/www/cacti/cacti.sql
Now we’ve of the location of Cacti.sql file, type the following command to install tables, here you need to type the Cacti user password.
1 2 3 |
mysql -u cacti -p |
cacti < /var/www/cacti/cacti.sql
Configure MySQL settings for Cacti
Open the file called /etc/cacti/db.php with any editor.
1 2 3 |
# vi /var/www/cacti/include/config.php |
Make the following changes and save the file. Make sure you set password correctly.
1 2 3 4 5 6 7 8 9 10 |
/* make sure these values reflect your actual database/host/user/password */ $database_type = "<strong>mysql</strong>"; $database_default = "<strong>cacti</strong>"; $database_hostname = "<strong>localhost</strong>"; $database_username = "<strong>cacti</strong>"; $database_password = "<strong>your-password-here</strong>"; $database_port = "3306"; $database_ssl = false; |
Configuring Apache Server for Cacti Installation
Open file called /etc/httpd/conf.d/cacti.conf with your choice of editor.
1 2 3 |
# vi /etc/httpd/conf.d/cacti.conf |
You need to enabled access to Cacti application for your local network or per IP level. For example we’ve enabled access to our local LAN network 172.16.16.0/20. In your case, it would be different.
1 2 3 4 5 6 7 8 9 10 11 |
Alias /cacti /usr/share/cacti # httpd 2.4 Require host localhost # httpd 2.2 Order deny,allow Deny from all Allow from <strong>172.16.16.0/20</strong> |
Finally, restart the Apache service.
1 2 3 4 5 |
# /etc/init.d/httpd restart OR # service httpd restart |
Setting Cron for Cacti
Open file /etc/cron.d/cacti.
1 2 3 |
# vi /etc/cron.d/cacti |
Uncomment the following line. The poller.php script runs every 5mins and collects data of known host which is used by Cacti application to display graphs.
1 2 3 |
#*/5 * * * * cacti /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1 |
Running Cacti Installer Setup
Finally, Cacti is ready, just go to http://YOUR-IP-HERE/cacti/ & follow the installerinstruction through the following screens. Click Next button.
ID: admin
PASS : admin
참조 : http://www.tecmint.com/install-cacti-network-monitoring-on-rhel-centos-6-3-5-8-and-fedora-17-12/