Cacti on FreeBSD® 7.2
From BMO
Cacti is a complete network graphing solution designed to harness the power of RRDTool's data storage and graphing functionality. Cacti provides a fast poller, advanced graph templating, multiple data acquisition methods, and user management features out of the box. All of this is wrapped in an intuitive, easy to use interface that makes sense for LAN-sized installations up to complex networks with hundreds of devices.
This page contains information that has been adapted and referenced from the official Cacti website found here, the official CactiUsers : PluginArchitectureInstall page found here and the official cacti forums website found here.
Contents |
Requirements
Cacti requires the following packages to be installed prior it's installation:
- MySQL Server Database System
- Apache Webserver
- Php5 With MySQL and SNMP Support
- Net-SNMP
- RRDTool
All of the above packages have been installed and their installation details are found on the Nagios on FreeBSD® 7.2 page. Therefore we will first install the rrdtool and continue with the installation Cacti.
RRDTool
Install the rrdtool package using the following commands:
cd /usr/ports/databases/rrdtool/ make install clean
Use the default installation options that appear on the proceeding screens as shown below in fig.2 and fig.3.
If you happen to run into an installation error like the one shown below in fig.4, then deinstall and then reinstall xcb-proto package using the following commands:
cd /usr/ports/x11/xcb-proto/ make deinstall clean make rmconfig make install clean

fig.8
Then now install the libxcb package using the following commands:
cd /usr/ports/x11/libxcb/ make clean install

fig.9

fig.10
Now you can continue with the installation of the rrdtool package as above:
cd /usr/ports/databases/rrdtool/ make install clean
Cacti Installation
Cacti is installed by issuing the following commands:
cd /usr/ports/net-mgmt/cacti/ make install clean
Cacti Post Installation Configuration
MySQL
Log in to the MySQL database system using the following commands:
mysql -u root -p
MySQL Database
Create a cacti database using the following commands:
create database cacti;
MySQL User
Create a cacti database user (cacti_admin with a password of cacti_password) who will administer the cacti database using the following commands:
create user 'cacti_admin'@'localhost' identified by 'cacti_password'; grant all on cacti.* to 'cacti_admin'@'localhost' identified by 'cacti_password'; flush privileges;
Import MySQL Cacti Default Database
Import the cacti default database structure using the following commands:
mysql -u cacti_admin -p cacti < /usr/local/share/cacti/cacti.sql
Editing Cacti config file
Edit the /usr/local/share/cacti/include/config.php file to reflect the correct information using the following command:
ee /usr/local/share/cacti/include/config.php
The original /usr/local/share/cacti/cacti.php file looks like the one shown below in fig.20 edit it to look something like fig.21 shown below. 
fig.20

fig.21
Editing the crontab file
Open the /etc/crontab file using the following command:
ee /etc/crontab
Add the following line to the /etc/crontab file.
*/5 * * * * cacti /usr/local/bin/php /usr/local/share/cacti/poller.php > /dev/null 2>&1
Editing the Apache config file
Open the /usr/local/etc/apache22/httpd.conf file using the following command:
ee /usr/local/etc/apache22/httpd.conf
Add the following lines to the /usr/local/etc/apache22/httpd.conf file.
Alias /cacti "/usr/local/share/cacti/"
<Directory "/usr/local/share/cacti">
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Then restart the Apache webserver using the following command:
/usr/local/etc/rc.d/apache22 restart
Cacti Web Interface
Point your web browser which is in a separate computer to http://yourdomain.com/cacti or in this case http://192.168.6.37/cacti to get the Cacti web interface.

fig.28
If you are interested in adding cacti plugins to your cacti network graphing solution then proceed to the next section of Cacti Plugin Architecture below without touching anything on the web interface. If you continue the installation on the web interface, the installation of the Cacti Plugin Architecture after the completion of the cacti web interface installation will present with many installation errors. We will come back to the cacti web interface after we are through with the installation of the Cacti Plugin Architecture.
Cacti Plugin Architecture
The Plugin Architecture for Cacti is designed to be both simple in nature and robust enough to allow freedom to do almost anything in Cacti.
Download
Download the Cacti Plugin Architecture using the following command:
fetch http://mirror.cactiusers.org/downloads/plugins/cacti-plugin-0.8.7e-PA-v2.6.zip
Extract
navigate to the /usr/ports/distfiles/ and an ls to confirm whether the download is there. extract the archive using the tar binary and then do an ls to make sure you have a directory of the uncompressed archive named cacti-plugin-arch.
cd /usr/ports/distfiles/ ls
tar -xf cacti-plugin-0.8.7e-PA-v2.6.zip ls
Installation
There are two ways of installing the Plugin Architecture. I will only explain and not show the first way i.e Pre-Patched Full Files way but I will explain and show the second way which I recommend you to use.
Pre-Patched Full Files
The first way is by using the pre-patched full files. These files are the full install of the necessary files with the patch already applied to them. With these you can directly override the files already in your Cacti directory.
Using the pre-patched files is easiest and most straight forward way to install the Plugin Architecture. You will of course want to backup your Cacti install first before attempting any add-on modifications. Once you have backed up your install. Go to the directory that you extracted the Plugin Architecture to i.e /usr/ports/distfiles/cacti-plugin-arch/. In this directory you will find several other directories. One of them will look like this "files-0.8.7e". This is to show you that these are the pre-patched files for Cacti v0.8.7e.
Now you will need to determine where your original Cacti install is. In FreeBSD® 7.2, the original Cacti files are located at /usr/local/share/cacti/. You will now copy the files from the "files-0.8.7e" directory to your Cacti install directory i.e. /usr/local/share/cacti/, overriding any files if you are prompted.
From here you are done installing the Plugin Architecture, but it is necessary to configure it first before you continue using Cacti (or Cacti will probably not function properly!). The Configuration is shown below.
Patch File
The other way is by using the patch file. A patch file contains the difference between the original files and the "new" files, which makes them very small as they only contain exactly what you need to make the changes.
Using the patch file is slightly harder than using the pre-patched files, but it is recommended for anyone that has already modified their Cacti install using other mods, or their own custom tweaks. You will of course want to backup your Cacti install first before attempting any add-on modifications.But since this is a fresh install, we wont have to backup the Cacti install.
Now you will need to determine where your original Cacti install is. In FreeBSD® 7.2, the original Cacti files are located at /usr/local/share/cacti/. Now go to the directory that you extracted the Plugin Architecture to i.e /usr/ports/distfiles/cacti-plugin-arch/. In this directory you will find several files, one of them will have a name similar to this "cacti-plugin-0.8.7e-PA-v2.6.diff". This is a patch file that contains everything you need to install the Plugin Architecture.
Now navigate to the directory with the original cacti installation i.e. /usr/local/share/cacti/ and run the following command to patch the cacti installation.
cd /usr/local/share/cacti/ patch -p1 -N < /usr/ports/distfiles/cacti-plugin-arch/cacti-plugin-0.8.7e-PA-v2.6.diff
This will modify the files and report back. Assuming that all went well, then you can now proceed to configuring the Cacti install as shown below. If you receive any FAILED errors, then you know that you will run into a few problems. These problems are usually as a result if you had altered the original cacti installation thats why I insisted that the cacti web interface should remain untouched until the Plugin Architecture is installed.
Configuration
It is necessary to configure your Cacti install after installing the Plugin Architecture for several reasons.
- First you will need to open the /usr/local/share/cacti/include/config.php file and make sure the database username and password are correct as shown in fig.21 above.
- Second you will need to open the /usr/local/share/cacti/include/global.php file and enter the correct database username and password as shown in fig.21 above.
- Third in the same file (i.e. /usr/local/share/cacti/include/global.php) we now have a new config option which must be set in order for your Cacti install to function properly and this option is:
$config['url_path'] = "/";
You will need to set this option to the URL location of your Cacti install.
For instance, if your Cacti Install was reachable through a web browser at this location.
http://servername/ Then it would not be necessary to modify the above default location.
But if your Cacti Install was at
http://servername/projects/cacti/testing/ then you would need to set the option to this $config['url_path'] = "/projects/cacti/testing/";
If it is located here like in our case
http://servername/cacti/ i.e http://192.168.6.37/cacti/ then you would need to set this option to this $config['url_path'] = "/cacti/";
It is important to note that you must include the '/' at the front and end of the location. This is to prevent other issues later down the road.
Import the plugin architecture database file
The plugin architecture includes a pa.sql file. You will need to import this into your cacti SQL database using the following command.
mysql -u cacti_admin -p cacti < /usr/ports/disfiles/cacti-plugin-arch/pa.sql
Then restart the Apache web server.

fig.39
Cacti Web Interface Installation
Point your web browser which is in a separate computer to http://yourdomain.com/cacti or in this case http://192.168.6.37/cacti to get the Cacti web interface.
This will take you to the Cacti Installation web page. Click on next to continue with the installation.
Make sure New Install is selected and that information displayed about the database is correct then click on next to continue.
Make sure that all the values here are correct and that they are "FOUND". The common mistake here is not selecting the correct SNMP Utility Version which in our case is 5.x and also the correct RRDTool Utility Version which in our case is 1.3.x. In case you enter any wrong value here, go to Cacti Settings on the web interface and change the values there. Click on the Finish tab to complete the installation.
Enter admin as the cacti user name and the password as admin then click on Login.
You will be prompted to change your login password.
Here we will enter a login password of cactiweb and click on save.
Cacti Web Interface
After login the following page will be displayed which is the Cacti web interface.
Now go to the user management link and click on it.
In the user management web page, click on the admin link.
The user management admin web page will look the one shown below.
Click on the Plugin Management square to tick it. This allows the admin user to use the plugin management tool which installs and manages plugins.
Then click on save at the bottom of the page.
You will get a confirmation that the save was successful.
Now go back to the Cacti console and click on the Plugin Management link.
The Plugin Management web page looks like the one shown below.
Click on the Graph tab to view a sample of the localhost graphs as shown in fig.57 below.
Congratulations! the installation of Cacti and the Plugin Architecture is now complete.
Adding a Device
To add a new device, click on the Devices link on the left hand menu side bar or click on the Create devices link on the console page.
This will take you to the Devices page as shown in fig.59 below.
Click on the Add link which is somewhere on the top right hand corner as shown in fig.60 below.
This will take you to the new devices page.
Enter a meaningful name of the device you want to monitor on the Description field. and the IP address or a Fully qualified hostname for the device. Here we will use an example of router0 with an IP address of 41.204.160.30. If its a Cisco router select the host template of a Cisco Router. Select the SNMP version you are using on the router here we will use version 2. Also enter the SNMP Community name on the SNMP Community field here we will use an SNMP Community name of ayb4Ator. Remember to also use the same SNMP Community name in your router. This is done while in the configuration mode of the router by issuing the following command
config t snmp-server community ayb4Ator RO ^z wr
Then click on create.
You will get a confirmation that the save was successful.
Scroll down on the page and click on save.
This will take you to the devices page which will give you a confirmation that the save was successful and you can now be able to view the newly added device. Click on the New Graphs link on the side bar.
On the new graphs page select the host which you would like to create graphs for i.e. in our example select router0.
We will then create a template of Unix - Ping Latency which will graph ping latency of the device as shown in fig.68 below.
We'll also graph the total traffic of the 41.204.160.30 interface by clicking on the Fa6/0 interface which has the 41.204.160.30 IP address as shown in fig.69 below.
Scroll down to the bottom of that page and click on create.
This will create the total traffic graph but the ping latency graph requires more configuration. If you would like the graph to have a different colour other than yellow then you can select a different colour here. We will the default which is yellow. Then click on the create tab as shown in fig.71 below.
You will get a confirmation that the two graphs have been created. Then click on the Graph Trees link on the side bar.
This will take you to the Graph Trees page which only contains the Default Tree. We will add a new tree by clicking on the add link on the top right hand corner.
We will call this tree routers and then click on create.
Then click on the add button to add a device to the tree that you have just created.
This will take you to the Tree Items page as shown in fig.76 below.
Select Host on the Tree Item Type and then select router0 on the Host field. Thich will show all the graphs associated with router0. Then click on create.
You will get a confirmation that the save was successful and you will be able to view the host you have just added to the graph tree. Click on save again.
You will get a confirmation that the save was successful and now in order to view the graphs, click on the graphs tab as shown in fig.79 below.
Navigate through the tree by clicking on the routers, and then on the Host:router0. You will now be able to view the two graphs we created for this host. You might want to give Cacti some for the graphs to get populated with data.
You can add as many devices as you want, you can create graph trees of your choice and you can have any type of graph you want the only thing you will need is a graph template. Graph templates can be obtained from the Complete List of Cacti Scripts and Templates found here.








































































