Network Monitoring with Raspberry Pi, Part 2: SmokePing

Network Monitoring with Raspberry Pi, Part 2: SmokePing

In my previous post, I detailed how to install and configure Cacti on a Raspberry Pi. In this post, I’ll show you how to do the same with SmokePing, a latency graphing tool. The combination of the two make for a very useful monitoring and troubleshooting tool for SOHO/SMB networks. This process will work on both a Raspberry Pi Model B+ and a Raspberry Pi 2 Model B. If you’re planning to install both tools onto the same RPi, make sure to go through the Cacti install first. For some reason, Cacti cannot configure itself correctly when SmokePing is already installed, but SmokePing will install and run properly after Cacti has been installed. Also make sure you’re using a large SD card. I used 16 GB.

So SSH into your RPi and let’s get started. Remember to use sudo if you aren’t root.

apt-get update/upgrade (if you’re continuing on from the Cacti post, you can skip this step)

to make sure your package index is up to date.

apt-get install smokeping sendmail

to install smokeping and sendmail. After installing SmokePing by itself and having it not work, I did some searching and found that there is a bug which causes SmokePing to not work unless sendmail is present. This is annoying, as sendmail increases the install time on a Raspberry Pi significantly. So, grab more coffee and wait for it to complete.

Screen Shot 2016-02-11 at 3.06.50 PM

If you try without sendmail, you’ll see the error below in your browser when you try to access the web interface.

Screen Shot 2016-02-11 at 2.59.10 PM

Before we configure any graphs, we need to link the smokeping apache config, and then enable it and another file called mod_cgi. I believe this has to do with changes made to one package without the other being updated for it. Do this with the following commands.

cd /etc/apache2/conf-available

ln -s ../../smokeping/apache2.conf smokeping.conf

a2enconf smokeping

a2enmod cgid

service apache2 restart

Screen Shot 2016-02-12 at 9.12.56 AM

With that complete, you can open your browser and point it at hostname/cgi-bin/smokeping.cgi. With no config, you’ll see the page below.

Screen Shot 2016-02-12 at 9.15.42 AM

So, lets head back to our SSH session and edit some of the config. All the files you’ll want to change are located in /etc/smokeping/config.d/.

Screen Shot 2016-02-12 at 9.18.13 AM

The files you should configure are:

  1. General – the owner name, contact info, etc.Screen Shot 2016-02-12 at 9.36.37 AM
  2. Probes – configure the probes you want to use. I have only used fping. As an example, the probe below will send 10 pings every 60 seconds. The default config does not have those two lines. If you’re ok with 20 pings every 5 minutes (the default) then don’t add anything here.Screen Shot 2016-02-12 at 9.39.49 AM
  3. Targets – configure the hosts you want to monitor, such as workstations, servers, switches, routers, access points, or specific points on the internet.Screen Shot 2016-02-12 at 9.46.27 AM
  4. Presentation – configure the size and appearance of the graphs. I only change the width and height for the overview and detail sections to 1000 wide by 200 high. As with Cacti, you can set this to fit on your monitor as you please.Screen Shot 2016-02-12 at 9.49.51 AM

You can now point your browser at hostname/cgi-bin/smokeping.cgi. You may end up with the error seen here if you changed the Probes file.

Screen Shot 2016-02-12 at 9.52.29 AM

This is a result of changing the probe FPing, which was being used to gather data for the LocalMachine entry in the Targets file. It’s very simple to fix: remove the file mentioned in the error with the command

rm /var/lib/smokeping/Local/LocalMachine.rrd

This happens because the LocalMachine target is set up before you change the Probe value. As long as you set up all your other targets after you set your probe settings, you won’t have to remove any other .rrd files. If you remove the file, you must do service smokeping restart to recreate the .rrd file with the correct settings. Then refresh your browser, and voila!

Screen Shot 2016-02-12 at 9.58.40 AM

Screen Shot 2016-02-12 at 9.59.25 AM

The graphs take some time to populate as they gather data, but eventually you’ll see something like this.

Screen Shot 2016-02-12 at 11.17.50 AMYou can see that once students arrive at school around 8:40, latency goes up and we start experiencing some packet loss to the internet.

Thanks for reading, and please comment!

Facebooktwittergoogle_pluslinkedinmailFacebooktwittergoogle_pluslinkedinmail
  • John Tyra

    Great installation guide, thank you! 🙂 Very helpful! 🙂

    One item to note, the URL listed for SmokePing may not resolve “hostname/cgi-bin/smokeping” without the .cgi at the end of the URL. Mine required the suffix to load the page “hostname/cgi-bin/smokeping.cgi”. This was in Google Chrome.

    • Steve

      Thanks for pointing that out John. You are quite correct on the .cgi suffix, and it was an omission on my part.

  • Nick

    Thanks for your guides, they’re great! Just a heads up, your “previous post” link at the start of the article doesn’t seem to work 🙂

    • Thanks Nick, it sure was broken! I’ve fixed it now.

  • Van Hammersly

    Thanks for your writeups. I was able to throw together a quick monitoring stack using your guide for my small business.

  • Christopher Carpenter

    I am not sure where the disconnect is but I can not seem to get the graphs to appear. I get a broken image icon where the graphs should be. Do you have any potential solutions for my particular issue.

    • I’m not sure why you might be getting that issue. How long have you been waiting for the graphs to generate?

      • Christopher Carpenter

        I allowed it to run for a whole evening and when I checked in the AM the same result, I get a blank box where the graph should be with a broken image icon in the top left corner. I followed the guide to a T and still the same results. https://uploads.disquscdn.com/images/705ba7f6e098e60c279a82647520981e22bf5ed874f8e2f40c2d7793208209f5.jpg

        • Sounds like maybe a browser issue? If you right-click on the icon, does it give you an option to open the image? I see that the other images in the bottom left corner also aren’t showing up. Do you have another browser installed that you could try?

          • Matthias

            Sounds like a path-issue. Double-Check your configured settings for imgcache and imgurl (whilst imgurl should be identical to the last folder name in imgcache). Also, check that your apache-user (www-data or httpd, better check the name!) has read-access to the imgcache folder and the rrd files

  • Matthias

    Hey Steve! Thanks for the writeup! I stumbled upon your post whilst looking for raspberry-specific settings for the smokeping package.
    As a hint for the sendmail-situation: You don’t need to install the package. You can point the config to /bin/false – “sendmail = /bin/false”; smokeping will boot up with these settings without sendmail on the system (see https://wiki.archlinux.org/index.php/smokeping#Editing_the_config_file)

  • Deran Hood

    Hi Steve , Thanks for these very clear instructions. I have one request / suggestion. Seeing that the PI runs off the flash card is there a way to move the datadir to another mount point – on say a USB drive. Then if the constant writes to the date directory corrupts the flash, it is simple to replace, without having to redo the entire system build and configuration.

    • steve@greatwhitewifi.com

      Hi Deran. I’m sure you probably can do that, although I’m not sure how off the top of my head. The config overview here might help you.