Cacti
Cacti is a monitoring tool which has a very impressive User interface and is actually a frontend for the RRDTOOLS. It enhances the capabilities of rrdtools to the fullest. Cacti basically works on data collected by SNMP and graphs are plotted using Rrdtools which gives quite an overview of a system/network. MySql is the database used to store all the data collected.
Prerequisites:
- Rrdtools
- Apache with PHP support
- php
- snmp
- net-snmp
- php-snmp
- Mysql server
RRDTools:
Download RRDTools as per your hardware architecture and OS:
For Debian/Ubuntu:
http://packages.debian.org/stable/utils/rrdtool
For Redhat/CentOS/Fedora:
http://dag.wieers.com/rpm/packages/rrdtool
NOTE: Optionally, if your distro package manager (yum,apt-get,etc.) repositories are well updated you can install the same using the package manager. Most repositories contain rrdtools these days.
Apache with php support:
Note: I am considering the apache installation doesnot exist, if it does skip the apache installation and test if php support is enabled.
Issue the following commands as a root:
root@dork~ # wget -c http://www.hightechimpact.com/Apache/httpd/httpd-2.0.59.tar.gz
- Downloading the Apache source code from apache.org mirror site.
root@dork~ # tar zxpf httpd-2.0.59.tar.gz
- Extracting the downloaded content.
root@dork~ # cd httpd-2.0.59
- Change directory
root@dork~/httpd-2.0.59 # chmod a+x build.sh
- Adding the execute permission for build.sh.
root@dork~/httpd-2.0.59 # sh build.sh
- Executing build.sh, which basically is a shell script used for compiling apache with most of the frequently used and necessary options enabled. Optionally you can run ./configure
root@dork~/httpd-2.0.59 # make && make install
- Upon successfully configuring the sources, 'make' will compile all the data and 'make install' should install apache to /usr/local/apache.
Php:
root@dork~ # wget -c http://us.php.net/get/php-5.2.3.tar.gz/from/us2.php.net/mirror
- Downloading php sources
root@dork~ # tar zxpf php-5.2.3.tar.gz
-Unzipping the content downloaded.
root@dork~ # cd php-5.2.3
- Changing directory
root@dork~/php-5.2.3 # ./configure --with-apxs2=/usr/local/apache/bin/apxs --with-mysql
- Installing PHP for the apache we just installed with MySql support.
root@dork~/php-5.2.3 # make && make install
- This should compile the sources and install them to the default path.
root@dork~/php-5.2.3 # cp php.ini-dist /usr/local/lib/php.ini
- Setting up deafult php parameters in php.ini.
Add the following lines to /usr/local/apache/conf/httpd.conf:
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php .phtml
Restart the apache service:
root@dork~ # /usr/local/apache/bin/apachectl restart
If apache is already installed check that 'LoadModule php5_module modules/libphp5.so' exists in /etc/httpd/conf/httpd.conf for Redhat based distros or /etc/apache2/httpd.conf for Debian based distros.
Other packages:
For Fedora/Redhat:
root@dork~ # yum install snmp mysql-server net-snmp php-snmp
(if yum aint installed, RPM packages are easily available or can be installed from the install disks.)
For Debian/Ubuntu:
root@dork~ # apt-get install mysql-server snmp net-snmp php-snmp
MySql:
root@dork~ # /etc/init.d/mysqld start
- Starting mysql service.
root@dork~ # mysql -u root
- Connecting to mysql database, this will get you to mysql console where type in the following queries:
mysql> create database cacti;
mysql> grant all on cacti.* to root;
mysql> grant all on cacti.* to root@localhost;
mysql> grant all on cacti.* to cacti;
mysql> grant all on cacti.* to cacti@localhost;
mysql> set password for cacti@localhost=password('set_DB_passwd');
mysql> flush privileges;
mysql> commit;
mysql> exit
This should create a cacti database in mysql on which root and user cacti will be having all the grants required for Cacti to function smoothly.
Installing Cacti:
Now comes the fun part :))
Starting off with installing the main package, issue the following commands:
root@dork~ # groupadd cacti
root@dork~ # useradd -g cacti cacti
Note: As the time passes, Cacti generates a lot of data. In case you have structured disk space for application specific environment or for backup purpose, it is always a good idea to have the home directory on some other partition than /home. For me, I have it at /var/home/cacti.
root@dork~ # su - cacti
cacti@dork~ $ wget -c http://internap.dl.sourceforge.net/sourceforge/cacti/cacti-0.8.6j.tar.gz
- Downloading the cacti application.
cacti@dork~ $ tar zxpf cacti-0.8.6j.tar.gz
- Extracting the content.
cacti@dork~ $ ln -sf cacti-0.8.6j cacti
- Creating a softlink for easier access, just quickly run through all the permissions so that there wont be any problems.
cacti@dork~ $ cd cacti
- Changing directory
cacti@dork~ $ mysql --user=cacti --password cacti < style="font-weight: bold;">/home/cactiuser/cacti/include/config.php
$database_default ="cactidb;"
$database_hostname ="localhost;"
$database_username ="cacti;"
$database_password ="set_DB_passwd"
Add the following line to /etc/crontab:
*/5 * * * * cactiuser php /home/cactiuser/cacti/poller.php > /dev/null 2>&1
Add an alias or virtual host in your apache configuration file:
Alias /cacti/ "/home/cactiuser/cacti/"
Save and restart the apache and mysql service.
After restarting the service, open your browser and type the URL as http://localhost/cacti or http://server_IP/cacti and follow the installation instructions wizard that is launched. Upon successful completion of this, when prompted for login the default user/pass is admin/admin.
Hope this gets you started :))