Cacti on FreeBSD® 7.2

From BMO

Jump to: navigation, search

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

Figure-2.1.jpg
fig.1


Use the default installation options that appear on the proceeding screens as shown below in fig.2 and fig.3.

Figure-2.2.jpg
fig.2


Figure-2.3.jpg
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:

Figure-2.4.jpg
fig.4

cd /usr/ports/x11/xcb-proto/
make deinstall clean
make rmconfig
make install clean

Figure-2.5.jpg
fig.5


Figure-2.6.jpg
fig.6


Figure-2.7.jpg
fig.7


Figure-2.8.jpg
fig.8

Then now install the libxcb package using the following commands:

cd /usr/ports/x11/libxcb/
make clean install

Figure-2.9.jpg
fig.9

Figure-2.10.jpg
fig.10

Now you can continue with the installation of the rrdtool package as above:

cd /usr/ports/databases/rrdtool/
make install clean

Figure-2.11.jpg
fig.11

Figure-2.12.jpg
fig.12

Cacti Installation

Cacti is installed by issuing the following commands:

cd /usr/ports/net-mgmt/cacti/
make install clean

Figure-2.13.jpg
fig.13

Figure-2.14.jpg
fig.14

Cacti Post Installation Configuration

MySQL

Log in to the MySQL database system using the following commands:

mysql -u root -p

Figure-2.15.jpg
fig.15

MySQL Database

Create a cacti database using the following commands:

create database cacti;

Figure-2.16.jpg
fig.16

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;

Figure-2.17.jpg
fig.17

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

Figure-2.18.jpg
fig.18

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

Figure-2.19.jpg
fig.19

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. Figure-2.20.jpg
fig.20

Figure-2.21.jpg
fig.21

Editing the crontab file

Open the /etc/crontab file using the following command:

ee /etc/crontab

Figure-2.22.jpg
fig.22

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

Figure-2.23a.jpg
fig.23

Figure-2.24a.jpg
fig.24

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

Figure-2.25.jpg
fig.25

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>

Figure-2.26.jpg
fig.26

Then restart the Apache webserver using the following command:

/usr/local/etc/rc.d/apache22 restart

Figure-2.27.jpg
fig.27

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.
Figure-2.28.jpg
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

Figure-2.29.jpg
fig.29

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

Figure-2.30.jpg
fig.30

tar -xf cacti-plugin-0.8.7e-PA-v2.6.zip
ls

Figure-2.31.jpg
fig.31

Figure-2.32.jpg
fig.32

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 

Figure-2.33.jpg
fig.33

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.

Figure-2.34.jpg
fig.34

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.

Figure-2.35.jpg
fig.35

Figure-2.36.jpg
fig.36

  • 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/";

Figure-2.37.jpg
fig.37

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

Figure-2.38.jpg
fig.38

Then restart the Apache web server.
Figure-2.39.jpg
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.


Figure-2.40.jpg
fig.40

This will take you to the Cacti Installation web page. Click on next to continue with the installation.


Figure-2.41.jpg
fig.41

Make sure New Install is selected and that information displayed about the database is correct then click on next to continue.


Figure-2.42.jpg
fig.42

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.


Figure-2.43.jpg
fig.43


Enter admin as the cacti user name and the password as admin then click on Login.

Figure-2.44.jpg
fig.44


Figure-2.45.jpg
fig.45

You will be prompted to change your login password.


Figure-2.46.jpg
fig.46

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.


Figure-2.47.jpg
fig.47

Now go to the user management link and click on it.


Figure-2.48.jpg
fig.48

Figure-2.49.jpg
fig.49

In the user management web page, click on the admin link.


Figure-2.50.jpg
fig.50

The user management admin web page will look the one shown below.


Figure-2.51.jpg
fig.51

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.


Figure-2.52.jpg
fig.52

Then click on save at the bottom of the page.


Figure-2.53.jpg
fig.53

You will get a confirmation that the save was successful.


Figure-2.54.jpg
fig.54

Now go back to the Cacti console and click on the Plugin Management link.


Figure-2.55.jpg
fig.55

The Plugin Management web page looks like the one shown below.


Figure-2.56.jpg
fig.56

Click on the Graph tab to view a sample of the localhost graphs as shown in fig.57 below.

Figure-2.57.jpg
fig.57

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.

Figure-2.58.jpg
fig.58

This will take you to the Devices page as shown in fig.59 below.

Figure-2.59.jpg
fig.59


Click on the Add link which is somewhere on the top right hand corner as shown in fig.60 below.

Figure-2.60.jpg
fig.60

This will take you to the new devices page.

Figure-2.61.jpg
fig.61


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.

Figure-2.62.jpg
fig.62


You will get a confirmation that the save was successful.

Figure-2.63.jpg
fig.63


Scroll down on the page and click on save.

Figure-2.64.jpg
fig.64


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.

Figure-2.65.jpg
fig.65


On the new graphs page select the host which you would like to create graphs for i.e. in our example select router0.

Figure-2.66.jpg
fig.66


Figure-2.67.jpg
fig.67


We will then create a template of Unix - Ping Latency which will graph ping latency of the device as shown in fig.68 below.

Figure-2.68.jpg
fig.68


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.

Figure-2.69a.jpg
fig.69


Scroll down to the bottom of that page and click on create.

Figure-2.70a.jpg
fig.70


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.

Figure-2.71.jpg
fig.71


You will get a confirmation that the two graphs have been created. Then click on the Graph Trees link on the side bar.

Figure-2.72a.jpg
fig.72


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.

Figure-2.73.jpg
fig.73


We will call this tree routers and then click on create.

Figure-2.74.jpg
fig.74


Then click on the add button to add a device to the tree that you have just created.

Figure-2.75.jpg
fig.75


This will take you to the Tree Items page as shown in fig.76 below.

Figure-2.76.jpg
fig.76


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.

Figure-2.77.jpg
fig.77


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.

Figure-2.78.jpg
fig.78


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.

Figure-2.79.jpg
fig.79


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.

Figure-2.80a.jpg
fig.80


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.

Personal tools