GIT – In this handbook we will have a look at Cacti – The complete RRDTool based graphing solution. This handbook will not teach how to work with Cacti, doing so would only mean to duplicate the great documentation prepared for you by the Cacti team.
Table of Contents
- Database configuration for Cacti
- Configuring Apache and Cacti
- Using Cacti
- Installing Cacti Spine
So what is Cacti? Citing from the official web site of Cacti:
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.
You are advised to check and go through the Cacti online documentation for a comprehensive explaination of Cacti and the features it provides.
Below you will find FreeBSD specific instructions for installing and configuring Cacti. So let’s go ahead and install Cacti, shall we?
- root access or sudo rights
- You have installed and configured Apache web server with PHP, MySQL and SNMP support. If you don’t have this yet, please refer to the handbook for Installing Apache under FreeBSD. Keep in mind that you need to select the corresponding options for PHP, MySQL and SNMP before you start building Apache
- You have a running MySQL server. If you don’t have yet an installed and configured MySQL server, please refer to the handbook for Installing MySQL under FreeBSD.
In order to install Cacti we are going to use the FreeBSD Ports Collection.
First make sure that you have updated your Ports tree, and then let’s go ahead and install Cacti.
To install Cacti from the FreeBSD Ports Collection, execute the following command:
Once the installation is over you should see something similar:
Now let’s continue with the configuration.
Configuring the SNMP daemon on the machines to be monitored
In this step we will configure the SNMP daemon on the FreeBSD machines to be monitored.
You can skip this step, if your machines or routers already have configured SNMP daemons.
Here we are going to use the SNMP daemon that comes with the base FreeBSD system – bsnmpd(1).
You might also want to install a more extensible SNMP daemon like net-mgmt/net-snmp, but this is not in the scope of the current handbook.
The configuration for bsnmpd(1) resides is in the /etc/snmpd.config file.
Please refer to the manual page for bsnmpd(1) for more information about the different options and explanation of them.
In the configuration we are only going to change a couple of things, so again, please refer to the manual page of bsnmpd(1) for more information regarding the rest of the configuration options.
In the above configuration we set the read community to bsnmpd
To enable bsnmpd(1) during boot-time, add the following lines to your /etc/rc.conf file.
Now let’s start the SNMP daemon:
You will need to configure the SNMP daemon on each machine you want to monitor. Once you are ready with that, please proceed with the next step.
Database configuration for Cacti
Cacti is using a database backend for storing all the information about the devices it monitores.
In this step we will see how to create the database that will be used by Cacti later for storing it’s data.
Assuming you have read the handbook for installing and configuring MySQL server under FreeBSD, we will now create the database for Cacti.
So, first login to the MySQL server:
Now let’s create the database and user for Cacti:
Keep in mind that in the above SQL statements we define the following:
- cacti – The MySQL database Cacti will use
- cacti_user – The MySQL user that Cacti will use when connecting to the database
- some-password – Password for the MySQL account used by Cacti
- monitor.example.org – This is the server that Cacti will be running on
Now let’s create the Cacti database schema. This step needs to be executed on the server Cacti will be running on, e.g. monitor.example.org
The above commands will create the Cacti database schema, with all it’s tables and columns needed by Cacti.
Now we can configure Cacti and Apache in the next step of the handbook.
Configuring Apache and Cacti
Now let’s configure Cacti, so that it uses the database we have just created.
Cacti’s default install location is /usr/local/share/cacti – this is where the configuration files also reside.
Open /usr/local/share/cacti/include/config.php file for editing and enter the database name, username, password and server that will be used by Cacti:
Now let’s configure our Apache vhost for Cacti.
Assuming you have read the handbook for installing and configuring Apache under FreeBSD, we will now make some minor changes to the Apache configuration, so that our default Apache vhost points to Cacti.
The next thing to do is to add a cron job that polls your machines and routers each 5 minutes.
To do that add the following lines to your /etc/crontab file:
Now, let’s start Apache and start using Cacti. First we test the configuration for errors, and then we start Apache.
Configuration is OK, so now we can start Apache:
Now, please continue reading through the next chapter in order to do the initial setup of Cacti and start using it.
Before we can start using and monitoring devices via Cacti we first need to do the initial setup for Cacti.
To do that, open a browser and open the Cacti web interface, which should be on the http://monitor.example.org/ Apache vhost we’ve installed and configured.
Please follow the steps provided by the Cacti installer, so that you can do the initial configuration of Cacti.
When you are invited to login, use admin for the username and password – right after that you will be advised to change the default password to one of your choice.
Now you can start adding the machines and routers you want to be monitored by Cacti.
To do that just go to Console -> Devices -> Add and enter the needed information of the machine to be monitored.
Again, I would recommend that you now go and read the great Cacti online documentation, for more comprehensive explanation of how to use and configure the different aspects of Cacti.
Installing Cacti Spine
This step is optional. It just covers how to install and configure Cacti Spine – a fast poller for Cacti.
Spine is another SNMP poller that can be used by Cacti. It’s a good replacement for the default cmd.php poller that comes with Cacti and is quite fast.
If your environment constist of a lot of machines you might want to prefer using Cacti Spine just for that reason – speed.
To install Cacti Spine, we are going to use again the FreeBSD Ports Collection.
Once the installation of net-mgmt/cacti-spine is over, you should see something similar:
Let’s configure Spine. Open /usr/local/etc/spine.conf and enter the needed information – database server, username, password, database name and port.
Now we need to tell Cacti to use the Spine poller, instead of the default cmd.php one.
To do that, login to your Cacti web interface on http://monitor.example.org/ and go to Console -> Settings.
Then click on the Paths tab and somewhere near the bottom you should see a field to enter the Cacti Spine location poller. Enter the following in the field –/usr/local/bin/spine and then Save.
Then click on the Poller tab and choose Spine for the Poller Type option and again Save.
Again on the Poller tab, you can further configure Spine – how many threads to use, maximum SNMP OIDs per SNMP Get Request, etc.