Network Monitoring with Raspberry Pi, Part 1: Cacti

Network Monitoring with Raspberry Pi, Part 1: Cacti

A Raspberry Pi is a simple, yet powerful tool for a network administrator to have and be comfortable with. From throughput testing (a previous post of mine) to wireless analysis (Jake Snyder), a little bit of Raspbian know-how can get you a long way. In a two-part series, I’m going to show you how to install and configure Cacti, a network graphing tool, and SmokePing, a latency monitoring tool, on a Raspberry Pi. Both are free, can be installed with a few commands, and are very easy to configure. This post will cover Cacti, and the next will cover SmokePing. Note that I’ll be going over a very basic configuration. If you have specific questions, please comment. I’m not reinventing the wheel here, but came across a couple hitches and, after spending some time with the Great Google, felt like it all needed to be consolidated into one place. I’ve tested this on an RPi Model B+, and an RPi 2 Model B. Make sure to install Cacti first – for reasons unknown to me, Cacti wouldn’t install correctly if SmokePing was already present, but SmokePing will install properly with Cacti on the system first.

I’ve used Cacti in the past to graph throughput on switch ports, received signal levels and signal-to-noise ratios on point-to-point radios, the number of connected clients on access points, temperature, CPU and memory usage, and other critical statistics on many types of networking gear. Paired with SmokePing, you can compare physical interfaces statistics with network traffic and latency to greatly reduce diagnosis and troubleshooting time. Cacti comes with some basic graphs and templates that use SNMP, but you can create custom ones if you have access to the MIBs or use a tool called Net-SNMP. There are also templates available on the Cacti forums. While I wouldn’t suggest using an RPI to monitor a large enterprise network, a SOHO/SMB setting can benefit greatly from the simple setup and helpful visualizations presented in these blog posts. I know a gentleman who had Cacti set up on his home network, and busted his son for playing Xbox while grounded. He could see the traffic to the device start flowing when his son got home from school.

If you’re new to the Raspberry Pi world, I suggest you check out my previous post on setting up your RPi. If you’re familiar with Raspberry Pi and Raspbian, then let’s dive in.

I used Raspbian Jessie Lite for the OS on this RPi. At 1/3 the size, it reduces both download and imaging time. It also saves you from downloading unused packages when updating and upgrading packages. So, assuming you have your SD card imaged and are able to SSH to your RPi, here are the steps for installation. Grab some coffee and remember to use sudo if you aren’t root.

dpkg-reconfigure tzdata

to select your location, which will set your time zone; graphs use time for the x-axis, and you probably want that reported in local time. Mine is America-Winnipeg.

apt-get update

to update the package index.

apt-get upgrade

to upgrade installed packages; this may take 10 minutes or more, depending on your internet connection.

apt-get install cacti

to install Cacti and all required dependencies; again, this may take some time. Create passwords as requested, ignore the warning about the php path, and select your web server. Apache2 is installed as a dependency, so I recommend that one. Also select the dbconfig-common.

Open a browser and head to RPihostname/cacti (eg. type into the address bar if your RPi has an IP address of You’ll have to step through the installation guide. It’s basically a click-through for new installations. Accept the defaults at all three screens and you’ll be fine.

Screen Shot 2016-02-11 at 11.32.36 AM

The default username and password is admin for both. You will be forced to change the admin password immediately.

Screen Shot 2016-02-11 at 11.33.16 AM

You’ll end up here. Time to add a device and create some graphs.

Screen Shot 2016-02-11 at 11.33.35 AM

To add a device, click “Devices”.

Screen Shot 2016-02-11 at 11.50.23 AMClick “Add” in the top right corner to get to the New Devices screen.

Screen Shot 2016-02-11 at 11.51.56 AM

Then enter a meaningful description, the hostname or IP address, the host template (Generic SNMP-enabled Host will pull throughput data from most switches), the SNMP version and SNMP community, then click Create. If all your information was correct, you’ll see some SNMP information from the device.

Screen Shot 2016-02-11 at 11.52.24 AM

You can click on “Create Graphs for this Host” to start graphing.

Screen Shot 2016-02-11 at 11.53.48 AM

Select the interfaces you want to create graphs for, and then in the bottom right, select the type of graph you want to create, and click Create. I like the In/Out Bits with Total Bandwidth, as it graphs the throughput in megabits per second and provides a total of transferred data in megabytes or gigabytes at the very bottom. You can experiment with different ones to see what fits your needs. You should see a list of your successfully created graphs at the top of the screen. Next, you need to add them to a graph tree in order to view them. Click on Graph Trees, and then on Default Tree.

Screen Shot 2016-02-11 at 11.54.48 AM

Screen Shot 2016-02-11 at 11.55.05 AM

You  may want to rename the tree to something else, such as a site name. Click Save, then after the screen refreshes, click Add.

Screen Shot 2016-02-11 at 11.55.21 AM

For Tree Item Type, select Host. You can then select the device you added in the Host drop-down. Click Create, and you will see something like the image below.

Screen Shot 2016-02-11 at 11.56.01 AM

After that, click on the Graphs tab in the top left, and Click down through the tree until you find the device you created. Remember that the graphs take some time to gather and populate data, so you may not see them right away. While you wait, check out some of the other settings available in the console, specifically the Poller settings. Click Console, then Settings (towards the bottom left), then the Poller tab.

Screen Shot 2016-02-11 at 12.21.04 PM

You can set the poller interval to 10,15,20,30 seconds, 1 minute or 5 minutes, depending on your requirements. Keep in mind the consequences of reducing the interval, the most obvious being more management traffic on your network and more storage space required. You can also create read-only users in the User Management menu, or change the graph templates in the Graph Templates menu. One thing I like to do is change the size of the graphs to 200 pixels high by 1000 wide. Depending on your monitor size, you can go bigger. The default size of 500×120 is very small on a modern display. You can also create your own graph templates or change the way the data is presented, such as different colours, line types, fonts and fills. You end up with something like this.

Screen Shot 2016-02-11 at 12.32.54 PM

You can zoom into time periods down to a few minutes. The image below really illustrates the poller interval being set at 5 minutes.

Screen Shot 2016-02-11 at 12.41.09 PM

Your graphs should have been populated now, so go back to the Graphs tab and check them out. Give it an hour or so to gather some data, and enjoy knowing what your network traffic looks like. You’ve now installed Cacti, added a device and created some graphs. As I said, Cacti is a powerful tool and with some experimentation and research, you can graph almost anything you want to know about your network. I cover SmokePing latency graphing in this post. Thanks for reading, and please comment with any questions.


  • Arthur

    Thank you for an easier to understand article. As a beginner with the Pi, too many writers lose sight of the fact that Pi is a learning experience.

    A question, if I may: I would like to use my Pi, attached directly to my Cisco cable modem, to measure and log speed down/up but cannot figure how to set up cacti for that. Any suggestions or instructions you might refer me to?

    • Arthur, Cacti as I have used it will only monitor the traffic that flows through the device. It will not run speed tests and log results, which, if I understand correctly, is what you are hoping to do. Is that correct? You can check out the Cacti forums at to look for add-ons and such. You could also check out NetBeez at, a monitoring solution with a cloud-based dashboard. They have a free tier and are quite user-friendly once you install the agent on a RPi.

      • Arthur

        Thank you for the explanation and suggestions!