Cacti and Custom Data Source Monitoring Part 1 of 2

Cacti and Custom Data Source Monitoring Part 1 of 2

Introduction and Background

I had posted about Cacti and setting up graphing from unorthodox data sources before. When I stepped back through those documented steps, I didn’t get the expected results. The inaccurate and vague information on that post prompted me to take a hard top to bottom look at the process. For anyone that had viewed that post and become confused by it, I do apologize. I dedicate this post to you as a humble attempt to right my wrong on the subject of Cacti.

On the Raspberry Pi, I’ll be creating a completely new system that will start with the installation of the OS. The OS that I’ll be working with is MATE, but you can do the same with any other supported flavor of Linux. From there I’ll go on to install the dependencies required for Cacti to run. Next, we’ll cover the steps of installing Cacti and some basic configuration. Once that is done, we will have a working Cacti platform from which we can start with.

The native data sources supported by Cacti will be covered and I’ll step through how to setup those. Next, we’ll cover how to create custom data sources. This will allow Cacti to be used as a tracking mechanism for any number of applications.

Once we have Cacti recording our data values from various sources, I’ll cover the graphing functions. Next I’ll cover some additional plug ins supported by Cacti and how to install them.

When all is said it done, you should have an extensive picture of Cacti. With that knowledge I hope you will be able to do some advanced tasks with Cacti. Let’s begin.

Installing the MATE Operating System on the Raspberry Pi

The distro I’ll be using is Ubuntu MATE 16.04.2 LTS for Raspberry Pi 2 and 3 systems. The website for the OS can be found here, I suggest reading the details about the distro as it points out some items that will make your experience a better one. Speaking of making things better, consider making a donation to the development team. In their words, “If everyone who downloaded Ubuntu MATE donated $2.50 it would fund the full-time development of Ubuntu MATE and MATE Desktop.”

It’s good practice to checksum your download. The Ubuntu MATE site provides a hash for the download. Mine happens to be this string “dc3afcad68a5de3ba683dc30d2093a3b5b3cd6b2c16c0b5de8d50fede78f75c2”. To verify that download is valid, use this command against the downloaded file.

sha256sum ubuntu-mate-16.04.2-desktop-armhf-raspberry-pi.img.xz

The Raspberry Pi uses microSDHC media as its “hard drive”. You’ll need to take additional steps to prepare the media so the Raspberry Pi can boot MATE from it. The Ubuntu MATE site suggests a few different methods on how to load the distro image onto the microSDHC media. I’m working from a Linux system, so I’ll use steps based on that OS. If you have a Windows or Apple platform, choose steps in accordance to those operating systems.

From the Linux terminal window, enter this command

unxz ubuntu-mate-16.04.2-desktop-armhf-raspberry-pi.img.xz

Then I use the GUI version of DDRescue and choose the media to work with. This has been a good way for me to avoid imaging a drive on my computer, versus my intended target. I like to pause and double check. Remember to measure twice and cut once.

Once the image has been copied, insert it in the Raspberry Pi. Connect the Raspberry Pi to a network connection, a KVM (keyboard, video monitor, and mouse), and a power source. From there you will see the OS start to load.

My system did a file system resize to take up the remaining free space on my 32GB microSD card. When it finished, the Raspberry Pi rebooted.

Following the reboot, I got the usual prompts to finish up the installation. I selected the pertinent information for my system.

  • Language
  • Time Zone
  • Keyboard Layout
  • User Account and login preferences

When all was said and done, my MATE operating system was done. Next I ran updates, removed old items, and rebooted by issuing these commands.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get autoremove

It’s good practice to do a reboot following any update, even if the system doesn’t prompt to do a reboot. I ensures that processes run with the newer code instead of the old code still occupying memory.

Settings On Firefox

One other thing I like to do with my MATE install is to set Firefox to preferences that I find personally favorable.

On the new tab option I choose show blank page. The reset of these options are set in the Preferences section.

Under General:
When Firefox starts: Show a blank page
Under Search:
DuckDuckGo only – remove all others
uncheck – provide search suggestions
Under Security:
Uncheck – Remember logins for sites
Under Advanced:
Under General:
Check – Warn me when websites try to redirect or reload the page
Under Data Choices:
Uncheck – Enable Firefox Health Report
Under Update:
Uncheck – Auto Update Search Engines
Close Firefox and reboot

Apache Web Server Install

Now it’s time to complete the AMP of our LAMP setup. In case you didn’t know it, LAMP stands for Linux Apache MySQL PHP. It’s going to be a requirement for us to operate Cacti on the Raspberry Pi.

Here are the steps I found and worked for my instance. First I installed the Apache web server by issuing this command in the terminal window.

sudo apt-get install apache2

I then tested the install by opening firefox and going to this URL, http://localhost, yes it worked. Next, I installed PHP by issuing this command in the terminal window.

Installing PHP

sudo apt-get install php libapache2-mod-php

This loaded version 7.0. A lot of “how-to” instructions I found online used a version of PHP that has since been superseded. For some reason this information remains when doing searches for instructions on how to install PHP on Linux. Anyway, my command worked. Next, I created a test PHP page for me to verify that my install worked. I like to use nano, but you can use any text editor so as long as you run it as super user.

sudo nano /var/www/html/testphp.php

I then entered this code in the new file.

<?php phpinfo(); ?>

I then saved it and did a test by going to the URL, http://localhost/testphp.php. Sure as anything, it worked. Next up I installed my last component for our Cacti requirements and that is MySQL. I issued this command in a terminal.

Installing MySQL Database Server

sudo apt-get install mysql-server

When you do, you’ll get a prompt for the DB root password. Be sure you remember it, you’ll need it later. Safegaurd it and don’t use something simple. Next I installed MySQL management tools that run ontop of PHP, this was my logic behind installing PHP before MySQL. I issued these commands in the terminal.

sudo apt-get install php-mysql phpmyadmin

I selected apache2. Next I configured the phpmyadmin database and set the password for DB. Next I restarted my Apache webserver service using this command.

sudo /etc/init.d/apache2 restart

After the service restarted, I checked that I could access MySQL using the PHP admin site with this URL, http://localhost/phpmyadmin, all worked nicely.

I then rebooted again for good measure.

Installing Webmin

Now, I also installed WEBMIN because managing a Linux system through command line is a pain. Also, since this system will be mounted inside an enclosure, it’s going to be running headless.

I did my setup using these commands at the terminal.

cd Downloads
sudo dpkg --install webmin_1.831_all.deb

My system complained about missing dependencies. I used this command to get past that problem.

sudo apt-get -f install

By the graces, my WEBMIN install continued on as if no problem had occurred.

Setting up webmin (1.831) …

The WEBMIN install completed and I tested teh site by going to the URL, https://localhost:10000. Firefox warned me that the connection was not secure. I logged in using my MATE operating system user name and password. It was a nice surprise to see that the WEBMIN interface has been updated with some nice aesthetics. The real treat about WEBMIN is it tells you about pending updates. Sure as anything, I had several to apply.

After installing the updates, I rebooted.

Installing Cacti

Now we are finally able to start with the installation of CACTI. Since we covered so much material, I’m going to break this post up into 2 sections. I’ll at least get you up and running with CACTI in this post. We’ll cover all the custom data source stuff on the next post.

Installing Cacti was done using this command at the terminal.

sudo apt-get install cacti

I entered the password for DB then selected apache2 from the list. That was it, it was done installing. I tested the site by going to the URL, http://localhost/cacti.

Next, I stepped through the initial configuration. During the Cacti Installation Guide I selected New Install. During the first login admin/admin is used and you’ll be prompted to change the password.

That was it, the site came up with the following preloaded data sources that were being graphed.

Localhost – Load Average
Localhost – Logged in Users
Localhost – Memory – Free
Localhost – Memory – Free Swap
Localhost – Processes

Under Management / Devices / Localhost / Create Graphs for this host, I decided to add the media partitions size and use from Data Query list. This lets me know if I’m running out of space on my boot and main partitions. Running out of space on the boot partition can be a update nightmare. I’ve been though this and it’s best to avoid.

Next, Under Management / Graph Tree / Default Tree, I added Tree Items types for each graph and removed header and host. Tree view doesn’t work for some reason, but preview view does. I’m thinking this has something to do with Linux. If I view the cacti site from another system it displays correctly.

Some Basic Cacti Preferences

The last thing I’ll cover in this post is changing the graph appearance. Under Settings tab I changed the graph settings as such.

Default Graph View Timespan – 6 hours
Thumbnail Height – 210
Thumbnail Width – 460

That’s it for now. My Cacti site is now graphing some basic metrics of my Raspberry Pi. Also, I’m able to do patch management easily with Webmin and perform other functions that I’ll cover in more detail in my next post. Thank you for joining me again. I hope this has been informative and useful.

Comments are closed.