Home Cloud & Networking Cacti Beginner's Guide - Second Edition

Cacti Beginner's Guide - Second Edition

books-svg-icon Book
eBook $39.99 $27.98
Print $48.99
Subscription $15.99 $10 p/m for three months
$10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
BUY NOW $10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
eBook $39.99 $27.98
Print $48.99
Subscription $15.99 $10 p/m for three months
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
  1. Free Chapter
    Installing Cacti
About this book
Cacti is a performance measurement tool that provides easy methods and functions for gathering and graphing system data. You can use Cacti to develop a robust event management system that can alert on just about anything you would like it to. But to do that, you need to gain a solid understanding of the basics of Cacti, its plugin architecture, and automation concepts. Cacti Beginner's Guide will introduce you to the wide variety of features of Cacti and will guide you on how to use them for maximum effectiveness. Advanced topics such as the plugin architecture and Cacti automation using the command-line interface will help you build a professional performance measurement system. Designed as a beginner's guide, the book starts off with the basics of installing and using Cacti, and also covers the advanced topics that will show you how to customize and extend the core Cacti functionalities. The book offers essential tutorials for creating advanced graphs and using plugins to create enterprise-class reports to show your customers and colleagues. From data templates to input methods and plugin installation to creating your own customized plugins, this book provides you with a rich selection of step-by-step instructions to reach your goals. It covers all you need to know to implement professional performance measurement techniques with Cacti and ways to fully customize Cacti to fit your needs. You will also learn how to migrate Cacti to new servers. Lastly you will also be introduced to the latest feature of building a scalable remote poller environment. By the end of the book, you will be able to implement and extend Cacti to monitor, display, and report the performance of your network exactly the way you want.
Publication date:
December 2017
Publisher
Packt
Pages
420
ISBN
9781788299183

 

Chapter 1. Installing Cacti

So, you have decided to install the Cacti tool. Throughout this book you will learn how to use Cacti and learn new things about it. This book will build up your knowledge, from chapter to chapter, as you complete the tasks. As you go through the book, you will see different information boxes and tips, and I encourage you to read through them as they provide valuable information. At the end of each chapter you will see a summary of what has been covered in the chapter and what you will learn in the chapter to follow.

Let's get on with setting up Cacti 1.x. Take a look at what we will do next. In this chapter we are going to cover:

  • Installing the prerequisites for Cacti on a CentOS 7 system
  • Installing Cacti on a CentOS 7 system and Windows 2012 R2 system
  • Compiling and installing the Spine poller
  • Upgrading an existing Cacti installation
  • Running Cacti for the first time
  • A quick overview of the Cacti web frontend

Here we go...

 

Preparing the system - basic prerequisites


In order to install and run Cacti, we need to make sure that all system prerequisites are met. Here we'll give an overview of the different components needed.

Web server

As most of Cacti is built as a web interface, a web server is needed. This can be Apache's HTTPD or Microsoft Internet Information Server if installing on Windows, but, in fact, any PHP-capable web server can be used to run the web interface. For optimal support, the use of Apache or IIS is suggested.

PHP

Cacti has been built with the PHP programming language, and therefore needs PHP to be installed on the system. Most Linux distributions already have a base PHP environment installed but some might need additional packages for Cacti to function properly. In particular, the LDAP, SNMP, and MySQL extensions should be installed. Be aware that Cacti 1.1 does not support PHP 7.1.

MySQL database

Cacti uses the freely available MySQL and MariaDB database engines for its database server and they are available for most operating systems. One should note that the database server does not need to be installed on the same host as Cacti. For best performance and to avoid stability issues with the Spine poller, MySQL version 5.6 or MariaDB 10.x should be used.

NET-SNMP package

The NET-SNMP package provides the SNMP binaries used by Cacti and supports SNMPv1, SNMPv2c, and SNMPv3. The NET-SNMP package also provides the SNMP daemon for Linux.

 

Installing Cacti on a CentOS 7 system


You're now going to install Cacti from source on a CentOS 7 system. You'll use CentOS 7 as it's 100% binary compatible with Red Hat Enterprise Linux 7, but in fact you can follow most of the installation process on other Linux distributions like Ubuntu or SUSE Linux as well. By installing from source you'll get some insight into the inner workings of Cacti, and it will also provide you with a system that most Cacti and plugin developers are used to. There are differences between a source installation and a yum/apt installation, but they will be described later on. Let's get started.

Preparing the system

Assume that the CentOS system has been installed with only the "Server" package selected and there is no graphical user interface installed.

This is the default installation for a CentOS system with no manual package selection.

Time for action - installing the missing packages and preparing the system

The default CentOS installation is missing several important packages. This section will show you how to install all required packages on your CentOS 7 system as well as the latest MariaDB 10.x version:

  1. Set up the MariaDB repository for installing the latest MariaDB version. You can get the latest repository from https://downloads.mariadb.org/mariadb/repositories/:
echo "# MariaDB 10.1 CentOS repository list - created 2017-02-08 16:11 UTC 
# http://downloads.mariadb.org/mariadb/repositories/ 
[mariadb] 
name = MariaDB 
baseurl = http://yum.mariadb.org/10.1/centos7-amd64 
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB 
gpgcheck=1" > /etc/yum.repos.d/MariaDB.repo 
  1. Now we can install all required packages for Cacti:
yum -y install mariadb-server php php-cli php-mysql net-snmp-utils rrdtool  
php-snmp gcc mariadb-devel net-snmp-devel autoconf automake libtool dos2unix wget help2man  
php-posix php-ldap php-mbstring php-gd 
  1. At this point you should also take care of updating your packages to the latest version. The following command will do this for you:
yum -y upgrade
  1. The next step will start the required MySQL/MariaDB server:
systemctl restart mariadb.service
  1. Cacti 1.x requires the timezone tables within MySQL to be populated. The following commands allow you to do so:
mysql_tzinfo_to_sql /usr/share/zoneinfo > /tmp/mysql_timezone.sql 
mysql -u root mysql < /tmp/mysql_timezone.sql
  1. The timezone settings for Cacti are very important, so you will need to set your current timezone. The following command will help you to do so:
timedatectl set-timezone Europe/Berlin
  1. Now that you have set your timezone, installed the MySQL/MariaDB server, and upgraded your system, you will have to set some special configuration parameters for MySQL/MariaDB. Edit the/etc/my.cnf file:
vi /etc/my.cnf
  1. Change your [mysqld] section. Make sure to change the time zone setting to your actual timezone:
[mysqld] 
datadir=/var/lib/mysql 
socket=/var/lib/mysql/mysql.sock 
symbolic-links=0 
max_heap_table_size=90M 
max_allowed_packet=16M 
tmp_table_size=64M 
join_buffer_size=64M 
innodb_file_per_table=ON 
innodb_buffer_pool_size=450M 
innodb_doublewrite=OFF 
innodb_additional_mem_pool_size=80M 
innodb_lock_wait_timeout=50 
innodb_flush_log_at_trx_commit=2 
collation_server=utf8_general_ci 
character_set_client=utf8 
default-time-zone='Europe/Berlin' 
innodb_flush_log_at_timeout=3 
innodb_read_io_threads=32 
innodb_write_io_threads=16 
  1. As you have already learned, the timezone setting is very important in Cacti. You already changed it for the database server and your system, but PHP also needs to be aware of your timezone. Therefore, you will now edit the /etc/php.ini file. While doing so you will also enable error logging for the syslog system, which will help you find issues with custom plugins. Now edit the /etc/php.ini file and set the following lines:
; Log errors to syslog (Event Log on NT, not valid in Windows 95). 
error_log = syslog 
... 
[Date] 
; Defines the default timezone used by the date functions 
; http://php.net/date.timezone 
date.timezone = Europe/Berlin 
  1. The next step will enable the web server as well as restart the required MySQL/MariaDB server. Use the following commands to start these:
systemctl start httpd.service 
systemctl restart mariadb.service
  1. Now that the web server is up and running, you should enable the http/https ports on the CentOS firewall. The firewall-cmd command will help you with this task:
firewall-cmd --permanent --zone=public --add-service=https 
firewall-cmd --permanent --zone=public --add-service=http 
firewall-cmd --reload
  1. As you want to have both services started automatically after a reboot of the system, you should also enable both services during boot time. This final step will allow you to do so:
systemctl enable httpd.service 
systemctl enable mariadb.service
  1. As a final step you should set the SELinux system to permissive. On a CentOS/RHEL system this can be done by editing the file /etc/selinux/config and setting the SELINUX variable to permissive, which will become active after the next restart:
SELINUX=permissive
  1. Before continuing it is now a good time to restart the system.

What just happened?

You just gave the system a location to find the remaining packages needed for the Cacti installation and then installed them. You also enabled the web server and database server to start at boot time. In addition, you have also set some very important system settings and disabled the SELinux setting. You are now ready to start the next installation phase.

Downloading and extracting Cacti

Go to http://www.cacti.net and download the latest version of Cacti. In the top-left corner, under Downloads, click on the Cacti link. You can download the Cacti files from there. Please also make a note of the latest stable version. You will need this information in the following steps. For simplicity, we're assuming that your server has an internet connection.

Note

Cacti version variable CACTIVERSION:  As the Cacti version may be different, we will use the CACTIVERSION or NEWCACTIVERSION variables during the different installation and upgrade steps to refer to the Cacti version. Check the current version on the Cacti website and change these variables accordingly.

Time for action - downloading Cacti

It's now time to download the latest Cacti version to your server. You will need your system username and password to login to your CentOS installation. If you have installed your CentOS system with the default settings, you should already have an SSH server running. If you're already logged in on the machine, you can ignore the first step:

  1. From a Windows machine, log on to your system using an SSH client such as Putty. If this is the first time you are connecting to the server, Putty will display a security alert and ask you to accept the RSA key. After doing so, Putty will display a logon prompt where you can log on to the system.
  2. Maximizing the window so long text lines do not break at the end of the line might make things easier.
  3. You'll need to become the root user in order to be able to set up Cacti properly. Should that not be an option, performing these steps with sudo should achieve the same results.
  4. Change to /var/www/html. This is the document root for Apache.
  5. Create the CACTIVERSION variable and set it to the current Cacti version
export CACTIVERSION=1.1.28
  1. To download Cacti, you can use the wget command. Enter the following command to download Cacti:
wget https://www.cacti.net/downloads/cacti-$CACTIVERSION.tar.gz
  1. You should see the following output on your screen:
  1. You now have the tar.gz file on your system, so let's move on and extract it. The following command will extract the files and directories contained in the archive to the current directory:
tar -xzvf cacti-$CACTIVERSION.tar.gz
  1. Finally, you are going to create a symbolic link to this new Cacti directory. This will allow you to easily switch between different Cacti versions later, for example, when upgrading Cacti. To create a symbolic link, enter the following command to create a link named cacti which points to the cacti-1.1.28 directory:
ln -s cacti-$CACTIVERSION cacti

What just happened?

You downloaded the latest Cacti version to the root directory of the web server and created a symbolic link to the extracted directory. With the Cacti files in place, you are now ready for the next phase of the installation process.

Creating the database

The database isn't automatically created during the installation of Cacti. Therefore, you are now going to create it here. At the same time, a database user for Cacti should be created to allow it to access the database. It's also a good idea to secure the MySQL database server by using one of the included CentOS tools or the commands provided.

Time for action - creating the database

For simplicity, let's assume that you're going to host the database on the same server as Cacti:

  1. Execute the following command to log on to the MySQL/MariaDB CLI:
mysql -u root mysql
  1. The default MySQL root account does not have a password set, so you can do it now:
SET PASSWORD FOR root@localhost = PASSWORD('MyN3wpassw0rd');
  1. You can remove the example database, as it is not needed:
DROP DATABASE test;
  1. Together with the example database, some example users may have been created. You can remove these with the following command:
DELETE FROM user WHERE NOT (host = "localhost" AND user = "root");
  1. On a CentOS distribution you can use the following command to guide you through the preceding steps:
/usr/bin/mysql_secure_installation 
  1. Now that MySQL is secured, let's create the Cacti database. Enter the following command. This will ask for the MySQL root password which you provided in setup step 1 or step 5. When finished, you'll have an empty database called cacti:
mysqladmin -u root -p create cacti 
  1. As the database is still empty, you need to create the tables and fill them with the initial data that comes with Cacti. The following command will do just that. Once the command finishes you'll have a working cacti database:
mysql -u root -p cacti < /var/www/html/cacti/cacti.sql
  1. Unfortunately, Cacti is still unable to access it, therefore you're now going to create a database user for Cacti. Enter the following command:
mysql -u root -p mysql
  1. You'll see the following on the screen:
  1. Type the next few lines in the MySQL prompt to create the Cacti user and allow him to use the time_zone_name table of MySQL. Make sure to choose a strong password:
GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost IDENTIFIED BY 'MyV3ryStr0ngPassword'; 
GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'MyV3ryStr0ngPassword'; 
flush privileges; 
exit

What just happened?

You used some tools to secure the MySQL server and created a database. You also filled the Cacti database with the initial Cacti data and created a MySQL user for Cacti. However, Cacti still needs to know how to access the database, so let's move on to the next step.

If you are not using CentOS to install Cacti, you can use some MySQL internal functions to secure your installation.

Configuring Cacti

You need to tell Cacti where to find the database and which credentials it should use to access it. This is done by editing the config.php file in the include directory.

Time for action - configuring Cacti

The database and some other special configuration tasks are done by editing the information in the config.php file:

  1. Change to the cacti directory:
cd /var/www/html/cacti/include
  1. Edit config.php with vi:
vi config.php
  1. Change the $database_username and $database_password fields to the previously created username and password. The content of the file should now look like the following:

There are many other settings within this file that we will explain in later chapters, so leave them alone for now.

What just happened?

You changed the database configuration for Cacti to the username and password that you created earlier. These settings will tell Cacti where to find the database and what credentials it needs to use to connect to it.

Creating the poller cron entry and Cacti's system user

For the poller to work correctly, Cacti also requires a system user account. You are going to create one now and also set up the poller's cron entry. We are going for a one-minute-based poller interval to prepare for the one-minute polling in a later chapter.

Time for action - creating the poller's cron entry and Cacti's system account

Let's create the cron entry so the poller runs frequently:

  1. To create a user called cactiuser, issue the following command as root. It will also add the user to the apache group:
adduser --groups apache cactiuser 
  1. Change to the cacti directory:
cd /var/www/html/cacti
  1. Change the ownership of the cacti directory, the newly created user, and apache. You will also change the permissions of some special directories as well as enable the apache user group to write to the rra and log directory. The setfacl command is important for some internal Cacti processes to work properly and makes sure that the apache user is able to write to these directories:
chown -R cactiuser.apache /var/www/html/cacti/ 
chmod -R 775 rra/ log/ resource/ scripts/ cache/ 
setfacl -d -m group:apache:rw /var/www/html/cacti/rra 
setfacl -d -m group:apache:rw /var/www/html/cacti/log
  1. Add the poller cron entry. Edit the cacti file in /etc/cron.d:
vi /etc/cron.d/cacti
  1. Add the following line to the file:
*/1 * * * * cactiuser /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&amp;1 
  1. Save the file.

What just happened?

You just created a system user that runs the Cacti poller, and scheduled the poller to run every one-minute. Cacti, by default, is still configured for a five-minute-based polling interval, but it can be changed to one minute if needed. The poller itself can run at different intervals. You are going to configure a one minute polling interval in a later chapter.

Installing the Spine poller

By default, Cacti comes with a poller written in PHP. For small to medium installations this poller does its job just fine, but for large installations an alternative poller needs to be used, and Spine is it. It's written in C and is much faster than the original poller because it uses the multi-tasking capabilities of modern operating systems and hardware.

Time for action - installing Spine

Here we will take a deep dive into installing and configuring the Spine poller:

  1. As with the Cacti main files, go to http://www.cacti.net and click on Spine under the Download section. Make a note of the latest stable version.
  2. If not already done, create the CACTIVERSION variable and set it to the current Cacti version:
export CACTIVERSION=1.1.28
  1. Change directories to /tmp/ and issue the following command:
cd /tmpwget https://www.cacti.net/downloads/spine/cacti-spine-$CACTIVERSION.tar.gz
  1. Extract the file:
tar -xzvf cacti-spine-$CACTIVERSION.tar.gz
  1. Change to the newly created directory:
cd cacti-spine-$CACTIVERSION
  1. Prepare the directory for compilation. Please note that this step may not work on other distributions, and additional steps may be needed:
./bootstrap
  1. Configure the compiling environment:
./configure  
  1. Compile Spine:
make
  1. Once the make command finishes, install Spine:
make install
  1. Now change the owner of the spine binary to root and set the sticky bit so you can use ICMP pings:
chown root:root /usr/local/spine/bin/spinechmod +s /usr/local/spine/bin/spine
  1. You now have Spine installed, but it needs to be configured. Therefore, copy the sample configuration file to a location where Spine will find it:
cp /usr/local/spine/etc/spine.conf.dist /etc/spine.conf
  1. Edit the file in vi:
vi /etc/spine.conf
  1. Change the database configuration to match the settings from earlier:
  1. Create a symbolic link in /sbin to the spine binary:
ln -s /usr/local/spine/bin/spine /sbin/spine

What just happened?

You just set up a basic development environment for compiling Spine, compiled it, and then installed it. You also configured Spine to use the correct database information.

Note

Compiling Spine on other Linux distributions:  When compiling Spine on other Linux distributions, such as Ubuntu, you will have to go through some additional steps. For more information, refer to http://docs.cacti.net/manual:100:1_installation.1_install_unix.6_install_and_configure_spine.

Differences between source and APT/yum installations

The main difference between installing Cacti from source and using apt/yum-based installations is the location of the configuration files and availability of patches. Cacti, by default, does not follow the Filesystem Hierarchy Standard (FHS) defined for Linux operating systems. The FHS defines directories where applications should add their configuration or log files. The apt/yum-based installations usually follow this standard. Due to this, add-ons such as the plugin architecture may not be available on all platforms using apt/yum.

The main advantage of using apt/yum based installations is the ease of installation, but as we've just seen, installing Cacti isn't very difficult.

However, the disadvantage of using apt or yum is the availability of newer Cacti versions. Source-based Cacti installations can be upgraded to the latest version as soon as they are available on the Cacti website, while apt/yum-based installs might need to wait until the package maintainers update their repositories.

Have a go hero - remote server for database hosting

Here is a little challenge for you. It's not difficult, but it will allow you to alter the installation to suit your needs. What if you want to use a remote database server? Maybe you want to use an existing, dedicated MySQL server instead of hosting the database on the same system as Cacti, or you want to separate the roles to allow more growth. Can you figure out what to change?

Solution: Create the MySQL database on the remote system using the same command as if installed locally but this time use the -h <hostname> option to specify the remote server. When creating the user and granting it permissions, use the following command, assuming the Cacti server has the IP, 192.168.0.10:

GRANT ALL ON cacti.* TO cactiuser@'192.168.0.10' IDENTIFIED BY 'MyV3ryStr0ngPassword'; 
flush privileges; 
exit

This will allow the Cacti user access to the database from the Cacti server. Now change $database_hostname in config.php and DB_Host in spine.conf on the Cacti server to point to your remote database server. On the database server, you will also have to allow traffic to the 3306 database port using the following firewall commands:

firewall-cmd --permanent --zone=public --add-port=3306/tcpfirewall-cmd --reload
 

Installing Cacti on a Windows system


The installation of Cacti on a Windows system is quite different from Linux. Most of the prerequisites that are already available on a Linux platform need to be installed on a Windows system. The MySQL database is an example of such a prerequisite. Here you can find more information about the Windows installation and how you can overcome most of the manual installation procedures by making use of the community-built Windows installer.

The community-built Windows installer

Instead of installing every prerequisite by hand, the community-built Windows installer provides a convenient way of installing them together with Cacti. It was built by a long-term Cacti user and forum member BSOD2600. The installer contains all the software and is also compatible with running Cacti on an IIS web server.

Note

For Cacti 1.x, there will not always be an up-to-date Windows installer available. Nevertheless, the main goal of the installer is to provide you with a convenient way of installing all required software with a single installer. Afterwards, you can download the latest Cacti version from the Cacti website and manually update.

Time for action - starting the Windows setup

Let's have a closer look at installing Cacti on a Windows system:

  1. Download the Windows installer to the system on which you want to install Cacti. To retrieve the latest version, go to http://forums.cacti.net/viewtopic.php?t=14946 and click the download link at the end of the first post. Save the installer to your desktop.
  1. Double-click on the setup file. The installer will check what has already been installed and give you a report. Click Next > after you have read the information:
  1. The next screen shows the GPL license. Accept it and click Next >:
  1. Then you must select a web server. If you have IIS installed you can select it here, otherwise Apache will be installed:
  1. In the next step you can choose the components to install. Select all available options. The Plugins section is empty as most plugins have been added to Cacti 1.x. Now click Next >:
  1. Keep the defaults for the installation locations and click Next >:
  1. The final step provides an overview of the paths to be created. Click Install to start the installation process:
  1. Please note the default Cacti admin and MySQL root passwords.
  2. Open the Post-Install instructions and follow the tasks.

What just happened?

You installed Cacti on Windows, along with all the prerequisites.

Installing the Spine poller under Windows

Unlike Linux, where compilation from source is the preferred method, the community-based installer already comes with pre-compiled binaries for Windows. This greatly eases the installation part of Cacti on a Windows system, so you can concentrate on the actual configuration of Cacti.

 

Upgrading Cacti


Upgrading Cacti involves several steps, one of which is backing up the database. Since you created a symbolic link to the Cacti directory, you don't need to backup any files but instead we copy or move them from the old version over to the new one.

Time for action - upgrading Cacti

  1. Create a backup of the database. The following command will back up the Cacti database to a file called cacti_backup.sql. You will be asked for the MySQL root password:
mysqldump -u root -p --lock-tables --add-drop-table cacti > /root/cacti_backup.sql
  1. Change to the /var/www/html directory. From http://www.cacti.net, download the source for the version you want to upgrade to.
  2. Create the CACTIVERSION variable and set it to the current Cacti version:
export NEWCACTIVERSION=1.1.28
  1. Extract the file. This will create a new directory named cacti-1.1.28:
cd /var/www/htmlwget https://www.cacti.net/downloads/spine/cacti-
    spine-$NEWCACTIVERSION.tar.gz tar -xzvf cacti-spine-$NEWCACTIVERSION.tar.gz 
  1. Change to the newly-created directory and edit include/config.php. Change the database entries in there to match your installation.
  2. Before copying any files, you should stop the poller using the web interface. Go to Configuration | Settings and change to the Poller tab. Disable the poller by unchecking it:
  1. Copy some files from your existing installation to the new one:
cp /var/www/html/cacti/rra/* /var/www/html/cacti-$NEWCACTIVERSION/rra/ 
cp -u /var/www/html/cacti/scripts/* /var/www/html/cacti-$NEWCACTIVERSION/scripts/ 
cp -u -R /var/www/html/cacti/resource/* /var/www/html/cacti-$NEWCACTIVERSION /resource/
  1. Set the permissions on the log and rra folders:
cd /var/www/html/cacti-$NEWCACTIVERSION/ 
chown -R cactiuser.apache /var/www/html/cacti-$NEWCACTIVERSION/ 
chmod -R 775 rra/ log/ resource/ scripts/ cache/ 
setfacl -d -m group:apache:rw /var/www/html/cacti/rra 
setfacl -d -m group:apache:rw /var/www/html/cacti/log
  1. Change the symbolic link to point to the new directory:
cd /var/www/html/ 
ln -fs cacti-$NEWCACTIVERSION cacti
  1. As Cacti 1.x requires the timezone data to be present in the MySQL/MariaDB database, you will have to import it here as well when upgrading from the 0.8.8 version of Cacti:
mysql_tzinfo_to_sql /usr/share/zoneinfo > /tmp/mysql_timezone.sql 
mysql -u root -p mysql < /tmp/mysql_timezone.sql
  1. You will also have to grant access to the timezone tables using the following SQL statement:
GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost IDENTIFIED BY 'MyV3ryStr0ngPassword';
  1. The final upgrade process is done using the web interface. Point your browser to http://<yourserver>/cacti/install and follow the steps. Make sure you select Upgrade on the second page.
  2. If you are upgrading from 0.8.8 to 1.x, the upgrade process will take some time to complete depending on your Cacti installation size.
  3. You can now enable the poller again using the Cacti web interface.
  4. Once you have checked that everything is working fine, you can remove or archive the original Cacti directory.

What just happened?

You upgraded Cacti to a newer version. As a safety net, you created a backup of the database so you can revert back to the old version in case of an error. You copied the RRD files and other resources to the new installation and switched over by changing the symbolic link to point to the new location. You finished the upgrade process by going to the install URL, which provides the final web-based upgrade process.

 

Using Cacti for the first time


After the installation of the database and files, there are still several additional configuration tasks left. For these tasks, you are going to use the web interface provided by Cacti to guide you through the final part of the setup. The following steps are almost identical for Windows and Linux.

Time for action - configuring Cacti

  1. Go to the installation URL: http://<yourserver>/cacti/install. Read the license agreement and click Next:
  1. The next page provides an overview of the different installed modules and database parameters. As you have installed all prerequisites and configured the database server according to these recommendations, you can Accept the GPL License Agreement and click Next here.
  1. The next page asks if you are installing a new system, a new remote poller, or upgrading an existing one. Choose New Primary Server then click Next:
  1. The next page provides an overview of all required binaries and paths. If you have followed the installation steps closely, all fields should be green. Make sure to set the theme to Classic:
  1. The following page will check for the correct files and folder permissions. If you have followed the installation guide, everything shows up green here. Click on Next to continue the installation:
  1. The final step allows you to import some pre-defined templates. Select all of the templates and click Finish to complete the installation:

What just happened?

You finalized your Cacti installation by running the included web-based installer. If you have been following the instructions, you will have a working Cacti installation.

The installation will leave you with the default cmd.php poller. If you want to use Spine, you will now have to log on to the Cacti web interface and set the Spine poller file path in the Paths section of the Settings page. You also have to change the poller type to Spine in the Poller section.

 

The Cacti web interface explained


The first time you log in, use the username admin and password admin (for Linux). You will be forced to change the admin password, but after doing so you will be presented with the Cacti web interface:

The initial page is called the Console and only administrators and users with special access rights are able to see it. From here you can fully administer Cacti.

The Console tab

The Console tab is where you manage your Cacti installation. From here you can add devices and users or create graphs and assign them to a tree. We're going to explain each of the menu sections here:

Create section

The Create section provides an easy access for new graph creations for specific devices. It's a shortcut to the create graphs link within each device.

Management section

The Management section, as its name says, allows the management of graphs, devices, data sources, graph trees, and the new Sites items as well as aggregate graphs. Sites is a new feature of Cacti and allows you to assign devices to a site. As with the old Cacti versions, within this section you can still add/edit or delete devices, delete graphs, add devices to trees, and much more.

Data Collection section

The Data Collection section describes the different ways that Cacti retrieves data from devices or systems. Here you can manage data queries such as SNMP retrieve methods, or manage the different input methods, which are used by external scripts called from the poller. With version 1.x, the new Data Collectors item has been added. Cacti 1.x allows you to have multiple remote pollers, and in this section you can add and manage these pollers. More to come in a later chapter.

Templates section

The Templates section provides an easy way of combining data templates into a graph (graph templates), graphs and data queries for a specific type of host (host templates), or different data source items (data templates). Many graph, data, and host templates are available on the Cacti forums.

Automation section

The Automation section is new in Cacti 1.x. It allows you to plan for automated network discovery as well as define rules for the automation of device and graph creation for auto-discovered devices. This section is based on the Discovery and Autom8 plugin which was already available for the 0.8.8 version of Cacti and has now been integrated into the main Cacti distribution.

Presets section

The Presets section allows you to configure the new VDEF rules as well as the old CDEF and GPRINT settings. The Data Profiles item is a new concept in Cacti 1.x. It defines the poller interval being used for the different data templates. This is where you will start the creation of a new one minute-based polling interval.

Import/Export section

The Import/Export section allows the import and export of templates. This is especially useful for providing templates of exotic devices to the Cacti community, or to import them from one of the many provided on the Cacti forum.

Cacti doesn't yet provide a method for importing or exporting other data (for example, device lists) from within the web interface.

Configuration section

Within the Configurationsection we can change the settings of Cacti. These settings include:

  • General settings (for example, logging levels)
  • Path settings (similar to the paths page from the installer)
  • Device default settings (SNMP version, timeouts)
  • Poller settings (number of threads, poller type to use)
  • Data storage settings (set remote or local RRD file storage)
  • Visual settings (size of the graphs, font size to use, theme to use)
  • Authentication settings (local authentication, LDAP or HTTP basic, password settings)
  • Data source statistics settings (enable/disable data source statistics collection)
  • Performance settings (enable/disable on-demand RRD file updates and image caching)
  • Spikes settings (enable/disable automated spike data removal)
  • Mail/reporting/DNS settings (set email options, configure nectar/reporting and DNS settings)

Utilities section

The Utilitiessection provides access to some basic system tools such as log or poller cache management, and hosts the user management interface.

The graphs tab

The graphs tab is the main screen for end users. Here they can view the graphs for their devices and systems, and also change some personal settings:

The graph tab contains a hierarchical tree to the left containing all devices a user is allowed to view. The main part of the page contains the graphs, and a filtering system for customizing the timeframe and graphs displayed based on a number of methods.

The nectar tab

The nectar tab provides you with some basic reporting functionality for Cacti. It is based on the Nectar plugin and has been integrated into Cacti 1.x:

The clog tab

The clog tab provides the common log viewer for Cacti. From here you can view the Cacti log entries currently logging with basic reporting functionality. It is based on the Nectar plugin and has been integrated into Cacti 1.x:

 

Before we continue


You now have a rough overview of the Cacti web interface and how it interacts with the database. You're going to dive a bit deeper into the details in the next few chapters, so it is not important at this stage to know where everything is or how it works in detail.

Pop quiz - a few questions about Chapter 1

  1. If you are using a remote database server, which configuration files do you need to change?

a) The config.php file and spine.conf b) The global.php file and config.php

  1. Which section on the Console tab allows you to change the path to the Cacti log file?

a) The System Utilities section b) The Path tab within the Configuration Sectionc) The General tab within the Configuration Section

 

  1. On a CentOS 7 system, how can you configure the MySQL server to start automatically during system startup?

a) You can use the enableservice command b) The setstartup command allows you to do so c) The systemctl command will do this

 

Summary


In this chapter, you have learned a lot of new information. You have learned how to download and install Cacti and how to set up the directory structure and permissions. You have covered how to create a database and fill it with the base Cacti data and time zone information, and learned how to configure Cacti to find its database. There have been topics about creating the Cacti system user and setting up the poller's cron entry for doing the actual monitoring work. You have also covered the installation of the Spine poller and looked into the process of upgrading an existing Cacti installation. Finally, you had a brief look at the different sections and parts of the web interface.

You're now ready to create your first few devices and graphs in the next chapter. So let's move on then!

 

Latest Reviews (3 reviews total)
good read. I got what i wanted from it.
books were without alternative, pricing was VERY fair (to me, i doubt the author has been that amused about itz)
best deal ever, had a deep discount
Cacti Beginner's Guide - Second Edition
Unlock this book and the full library FREE for 7 days
Start now