Installation of Cacti in windows Filed Under: Networks
Introduction
Before you start complaining and thinking that I’m gone mad and I moved back to windows and I’m just a windows guy and all the stuff, let me explain.
Basically, I would have love to have done this in a Linux or BSD machine but the only thing I had available at work was a windows PC and at that time I couldn’t be bother to install Linux or BSD on it because I was a bit lazy at that moment and I just wanted to get the application working. In my defense, I will plan to install Cacti in this server at some point so I will have a tutorial on how to install it in BSD once I done it.
For anyone that doesn’t know what Cacti is here is an excerpt from the Cacti website that explains what it is:
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. The frontend is completely PHP driven. Along with being able to maintain Graphs, Data Sources, and Round Robin Archives in a database, cacti handles the data gathering. There is also SNMP support for those used to creating traffic graphs with MRTG.
This tutorial is based on the tutorial in the actual cacti website on how to install Cacti under windows, you can find here.
Required applications
This is a list of required applications (the version are actually the ones I used in this installation):
- Apache web server. I used version 1.3.39.
- PHP. I used version 5.3.5
- ActivePerl. There is at this moment version 5.10 but I had problems with it but it works perfectly OK with version 5.8.8
- MySQL. I used version 5.0.45
- Net-SNMP. I used version 5.0.45
- Cygwin
- Cacti. I used version 0.8.7a
- cacti spine. I used version 0.8.7a
- rrdtool. I used version 1.2.15 (this was the latest precompiled version of rrdtool and as usual at that moment I didn’t feel like investigating how to compile the sources in windows.
Apache Configuration
Just an advice, before you install Apache. Install it under C:\Apache as the default location in the installation file is under C:\Program Files\ but if you put it there is going to be a nightmare to make cacti to work properly so just trust me (I did that silly mistake myself).
Once you have installed Apache and PHP add the following lines to the httpd.conf file under the conf directory.
LoadModule php5_module "C:/php/php5apache.dll"
AddModule mod_php5.c
Add the index.php
to the DirectoryIndex
entry so you have something similar to this:
<ifmodule mod_dir.c> DirectoryIndex index.html index.htm index.php
AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
Under <ifmodule mod_mime.c>
Once you finishing editing just save the file and restart the Apache service.
PHP
Install PHP under C:\php. Inside that folder is going to be a file called php.ini-dist, copy that file and rename it to php.ini.
Open that file and edit or uncomment the following parts:
doc_root = "c:\Apache\htdocs"
extension_dir = "c:\php\ext"
extension=php_mysql.dll
extension=php_snmp.dll
extension=php_sockets.dll
cgi.force_redirect = 0
If you want to be able to import templates uncomment this line:
file_uploads = On
Add the following windows system environment variables (right-click My Computer -> Properties -> Advanced Tab -> Enviroment Variables Button):
- Add to the PATH variable
c:\php
- Create a new variable called
PHPRC
and add the valuec:\php
. - Create a new variable called
MIBDIRS
and add the valuec:\php\extras\mibs
Cacti
Extract the cacti application inside a folder in the htdocs directory of the Apache webserver.
Inside that folder go the the folder Include and then edit the file config.php with the information about the mysql database. At the end you should have something like this:
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "password";
$database_port = "3306";
MySQL
Once you installed MySQL connect to the SQL database using the following command.
mysql -u root -p
This command will prompt you for the root password of the SQL database.
First of all we need to create a database for Cacti to use, with the command:
mysql> CREATE DATABASE cacti;
You can check that the database was created by using the command:
mysql> SHOW DATABASES;
After we have a working and setup database we will need to create a username and password for cacti to use when connecting to the cacti database. Create a user with the following command inside the mysql database:
mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'password';
After we have created the database we have to import the default database that comes with the cacti distribution using the following command from the command prompt (you need to exit the sql database):
mysql -u root -p cacti < c:\Apache\htdocs\cacti\cacti.sql
After you done all this, just verify you can connect to the cacti database using the username and password you specified by using the following command from the command line:
mysql -u cacti -p cacti
This will prompt you for the cacti user password.
Once you have connected successfully you can write the command:
mysql> SHOW TABLES;
To display all the tables in the cacti database (but this is optional and only do it if you want to make sure stuff is inside the database).
Cygwin
The following are the packages you need to install from Cygwin:
- Base (include all items)
- Libs
- libart_lgpl
- libfreetype26
- libpng12
- zlib
- openssl
- Utils
- patch
- Web
- wget
After you finished installing those application add the following entry to the PATH
enviroment variable c:\cygwin\bin
Spine
Install the application under c:\cacti folder.
As we have installed Cygwin delete all the dll files and the sh.exe file from that folder.
Finally, edit the file spine.conf with the information about the database so you have something similar to this:
DB_Host localhost
DB_Database cacti
DB_User cactiuser
DB_Pass password
DB_Port 3306
Remaining applications
For the remaining applications net-snmp, rrdtool and activeperl just install them with the defaults as they don’t need specific configurations.
Start engines!!!
Once we finished installing and configuring the required applications is time to start using cacti.
Point your browser to the following page: http://localhost/cacti.
The initial username and password is admin/admin. After you put that the application will ask you to change the password.
After you logged on to cacti, let’s make sure that cacti has find the path of all the applications.
To check that, go to Settings under Configuration. Under that page select the Path tab and check that everything is OK.
By default the localhost device (under management->devices) is configured for Linux based machines so we will need to delete it and recreate by specifying a windows machine template host. I won’t go into detail into how to create a new device as is quite straight forward.
Thanks for reading.
- Permalink
- Alberto Diaz
- 6 Jan 2008 5:24 PM
- Comments (1)
January 7th, 2008 at 1:03
Jo!
Da gusto ver como vuelves a escribir tutes. Sigue así porfa (no necesariamente a 3 por dia como hoy :P).
Ademas muy interesante, estuve mirando muy de cerca CACTI hace casi un año, y le perdí luego la pista, así que gracias también por recordarmelo.
Saludos hombre mitico!