Tracking network latency on FreeBSD with SmokePing

Tracking network latency should be an integral of anyone’s server management routine. It is essential that you monitor this regularly so you can get a better picture of your server’s health and performance. It can help you determine if your network is overloaded or indicate if there is an incorrect router configuration or downed device. Catching this kind of issues at the right time will help prevent major failures later on.

SmokePing is a network latency tracking tool that you may find very useful when monitoring network latency. This tutorial will assist you in setting up SmokePing with Apache on your server(s) running FreeBSD. All you need is a FreeBSD 11 server with a root user and Apache (and its FastCGI module) already installed and configured. Follow the steps below:

 

Installing and configuring SmokePing

  • The installation per se is quite simple because SmokePing exists already in the package repository. To proceed, enter the command below:

    sudo pkg install smokeping
  • Next, open the file at /usr/local/etc/smokeping/config, which you’ll need to edit to customize a few fields (the ones bolded below):

    sudo ee /usr/local/etc/smokeping/config
 
 *** General ***
 owner    = your_name
 contact  = your_email_address
 mailhost = my.mail.host
 . . .
 imgcache = /usr/local/smokeping/htdocs/img
 imgurl   = http://your_server_ip/smokeping/img
 datadir  = /usr/local/var/smokeping
 piddir  = /usr/local/var/smokeping
 cgiurl   = http://your_server_ip/smokeping.fcgi
  • Comment out the entire ***Slaves*** section.
# *** Slaves ***
# secrets=/usr/local/etc/smokeping/smokeping_secrets
# +boomer
# display_name=boomer
# color=0000ff
#
# +slave2
# display_name=another
# color=00ff00

  • Lastly, we turn to Targets. Simply put, targets are a hierarchical list of hosts which mark the limits of the network connections the system should monitor. In this tutorial, we’ll be setting up a configuration that monitors the latency between your server and two FreeBSD pkg mirrors. Thus, we’ll have a total of three graphs.

 

  • In the same file as above, navigate to the ***Targets*** section. What you’ll do first is delete the sample configuration so the end of your file looks like this:

    *** Targets ***
    
    probe = FPing
    
    menu = Top
    title = Network Latency Grapher
    remark = Welcome to the SmokePing website of xxx Company. \
             Here you will learn all about the latency of our network
  • Next, copy and paste the following configuration under the existing default settings.


    + targets
    menu = Targets
    title = Targets' Latency Probed with fping
    
        ++ pkgmir_nyi
        menu = FreeBSD pkg Mirror (NYI)
        title = FreeBSD pkg Mirror Hosted by New York Internet, USA
        host = pkg0.nyi.freebsd.org
    
        ++ pkgmir_ydx
        menu = FreeBSD pkg Mirror (YDX)
        title = FreeBSD pkg Mirror Hosted by Yandex, Russia
        host = pkg0.ydx.freebsd.org

 

  • Below it, add one more section to combine multiple targets into one graph.

    + multi
    menu = Multi Targets
    title = Multi Targets
    
        ++ multi_pkgmir
        menu = FreeBSD pkg Mirrors
        title = FreeBSD pkg Mirrors
        host = /targets/pkgmir_nyi /targets/pkgmir_ydx

Enabling the services

 

  • Next, we’ll start connecting and enabling the services.  For that, you’ll need to create a configuration file for Apache in /usr/local/etc/apache24/Includes/ called smokeping.conf, like so:

    sudo ee /usr/local/etc/apache24/Includes/smokeping.conf 
  • Then, paste this into the newly created file:

 

ScriptAlias /smokeping.fcgi /usr/local/smokeping/htdocs/smokeping.fcgi
Alias       /smokeping      /usr/local/smokeping/htdocs/
<Directory "/usr/local/smokeping/htdocs/">
        AddHandler      fcgid-script .fcgi
        AllowOverride   None
        DirectoryIndex  index.html smokeping.fcgi
        Options         FollowSymLinks ExecCGI
        Require         all granted
</Directory>
  • Now, enter these to commands so that default service configuration for Apache and SmokePing can start the processes at boot:
sudo sysrc apache24_enable="YES"
sudo sysrc smokeping_enable="YES"

 

  • Next, start Apache:
    sudo service apache24 start

 

  • Then, start the SmokePing service as well:
sudo service smokeping start

 

  • To access SmokePing’s web interface, go to http://your_server_ip/smokeping in your favorite browser. By navigating the menu on the left, and then clicking Targets, you will hopefully see the graphs that we’ve previously created and customized.

 

And that is all! You can track network latency on your server with SmokePing!

Leave a Reply