Tutorial and steps related to the installation, configuration, and use of the SmokePing software product for monitoring latency within network environment.
Background
The ability to monitor your network environments can be handled via a number of various tools and services, not the least of which are SaaS products provided through external vendors. If you are the “do it yourself” kind of engineer, exploring a tool such as SmokePing is an easy and affordable (free) way to get some very quick latency information exposed to your customers.
This post will explore the installation, configuration, and (basic) usage of the SmokePing product. It is intended to be a primer on the subject, not a full/in-depth tutorial and, as such, some aspects of the “productization” of the service will not be included.
Underlying Compute Technology/Ecosystem
This tutorial utilizes/makes the following assumptions about your compute infrastructure. Although the instructions can be extended to accommodate cloud-based and/or other infrastructure environments quite easily, all details are explained with respect to local development for the purposes of simplicity:
- Hypervisor Technology: VirtualBox
- Provisioner: Vagrant
- Number of VMs: 2
- Operating System: Ubuntu 16.04
- Arch: 64-bit
- CPUs: 2
- Mem: 4GB
- Disk: 50GB
This tutorial is built with 2 virtual machines serving as the compute resources - one of the resources will be the Master/UI instance while the other will be a dedicated poller/Slave instance. The following hostnames and corresponding IP addresses will be used for the 2 virtual machine instances:
- node1.localhost: 10.11.13.15
- node2.localhost: 10.11.13.16
The following software versions are used as part of this tutorial - again, versions can/may be changed, but there is no guarantee that using different versions will result in a working/functional technology stack. The versions listed are such that they represent a fully-functional and working technology ecosystem:
- RRDTool: 1.6.0 (dependency)
- Apache2: 2.4.18-2 (Master - UI web server)
- SmokePing: 2.6.11 (internal version 2.006011)
Finally, the code blocks included in this tutorial will list, as a comment, the node(s) that the commands following need to be run on. For instance, if required on both nodes, the code will include a comment like so:
If the code block only applies to one of the nodes, it will list the specific node it applies to like so:
All commands assume that your user is vagrant
and the user’s corresponding home directory is /home/vagrant
for the purposes of running sudo commands.
End State Architecture
At the end of this tutorial, the following end-state architecture will be realized:
Prerequisites/Dependencies
SmokePing requires several components to be installed prior to installing the software on your host system. Most Ubuntu-based distributions come with Perl pre-installed - if this is not the case, install Perl for your system using the native package manager. In addition, a C-compiler is required in order to install the versions of software specific to this tutorial. Note that we will install some prerequisites for both nodes up front in preparation for the Slave node configuration towards the end of the tutorial, while other packages are strictly installed on the Master due to the capabilities desired (i.e. sendmail for Email handling):
Once Perl is installed, you will need RRDTool - to install the version used in this tutorial,
perform the following steps. Note that the actual build and installation of the rrdtool software
is only done on node1.localhost
where the actual graphs are generated:
Following the installation, running the following command should result in the output of the rrdtool version installed:
This SmokePing installation is going to use the Apache web server with CGI support to display its web pages - install the Apache software/supporting module and create the SmokePing directory for serving the application via Apache:
Finally, we need to configure some defaults related to resolving the hostnames between the node1.localhost
and node2.localhost nodes. Update the /etc/hosts
file on each node to provide name resolution:
Installation
Once the installation prerequisites are in place, you can download and install the SmokePing product. First, download, extract, and compile the SmokePing package for the version you wish to install to the Master and Slave nodes:
To ensure that the appropriate Perl modules are in place, run the setup script to install any that
may be missing, along with the apt-get install
command for the librrds-perl package. Although the
RRD files and corresponding graphs are only generated on the Master instance, the build of the
SmokePing software will ultimately fail if the librrds-perl
package is not installed, so we will
install this on both instances:
Once the package has been extracted and dependencies for the Perl environment are in place, proceed to building and installing the software:
If the above commands were successful, you should be able to run the following and receive output corresponding to the version of SmokePing installed:
Configuration
Now that the SmokePing application code is in place, we can continue to configure the application
for use. In this particular installation, the configuration file was created with a trailing .dist
name. This will cause some issues with the way the scripts are expecting the configuration file to
exist and, as such, we will create a symlink to the configuration file without the .dist
trailing
name to ensure everything works as expected:
Edit the /opt/smokeping/etc/config file for your environment. There are a lot of configuration options available and the format is quite complicated - we will focus on a few paramaters to start with:
In addition to the above configuration changes, re-open/edit the configuration file to replace
the section ++ James
with the Master/localhost configuration information so that data can be
visualized for the Master instance:
Before starting the application, several directories must exist in order for the out of box configuration to function as expected, and certain permissions must be in place for the out of box security to work:
The Apache server needs to be configured to serve the web interface for the SmokePing application -
to configure this, copy the files from the SmokePing htdocs
folder into the respective Apache web
folder, and edit the Apache default virtual host file:
Once the configuration file is in place, enable the FastCGI and SUExec modules and restart the Apache web server:
Now that the web server is up and running, visit the web page located at http://10.11.13.15/ and you should see the SmokePing web interface presented to you. There is likely no data due to not yet having run any pollers to collect information.
We need to start the SmokePing daemon in order to start generating some data and graphs. Start by launching the application in the foreground (“debug” mode) and inspecting for errors:
After some time, the output will generate some results that ultimately result in some graphs being generated. Navigate back to your browser and reload the webpage - in the left menu navigation, select the “Targets -> node1.localhost” options to view the generated graphs. If no data appears but no errors are seen in the command-line debug session, leave the agent running in the foreground for a few minutes until the page appears with data.
If all is successful, you can terminate the foreground agent job and launch the smokeping agent in daemon mode to have it run continuously in the background on your Master node like so:
Refresh your web page and you should see updates to the graphs for the Master node (node1.localhost). The graph will appear towards the top of the page. You can also select the “Test -> node2.localhost” node to view the graph data for the Slave node as well (being pinged from the Master).
Slave Poller
Now let’s add a secondary poller on the Slave “node2.localhost”. This poller will check both the
Master and the Slave and will demonstrate distributing pollers on separate machines that report
back to the Master instance. Note that in order for the following configurations/setup to work, the
result of the command hostname
on the node2.localhost
node should report node2
.
First, we need to configure the Master instance to accept the Slave communication as well as tell the Slave which nodes to poll - update the configuration sections as follows on the Master:
Before reloading the configuration, we need to update the secret for the Slave to be able to communicate with the Master, and ensure the Apache process can read it:
Next, reload the configuration on the Master node for the new Slave information to take effect, and ensure that the Apache process is also restarted for this to work:
Once you’ve updated the configuration on the Master node, we need to set up the Slave instance. Note that if you try to view the web interface at this point you will likely see various errors corresponding to missing ‘slave1’ data/graphs - this is because the Slave has not yet been configured and communicated with the Master for the first time.
If you ran the commands to install the SmokePing on the Slave instance in parallel as the instructions at the beginning of this tutorial stated, you can simply proceed with the next steps (if you did not follow the instructions and do not yet have the SmokePing application installed, go back and repeat the relative steps for the Slave instance above).
First, there are a few Perl dependencies we need to install by hand since we did not install Apache and/or the relative dependencies associated with the Master instance:
Once complete, create a secret file on the Slave so that when the process starts it knows how to communicate with the Master instance, and secure the file:
Now you are ready to launch the poller:
If you received output as indicated, your Poller/Slave instance has successfully established connectivity and is communicating with the Master. If you received some other kind of output, inspect the log output to see what may have gone wrong.
Navigate back to the SmokePing web interface and refresh/reload the web page. You should now see stacked graphs showing poller results for the Master node poller along with a secondary graph indicating the results from the node2.localhost (Slave) poller. If there is no data within the secondary graph, give the poller a few minutes to finish its first round of polling and sending the results to the Master for rendering.
There are many more additional capabilities that are possible with this tool - this primer is stricly a starting point. Visit the project page for more information about the tool and its operation.
Disclaimers
As stated in prior tutorials, this tutorial is in no way intended to be a ‘production-ready’ setup. There are various tuning and configuration parameters, security settings, and overall architecture/directory structure changes that would need to be made in order to make this tutorial match a production-ready setup of the SmokePing application. It is intended to be a primer of installing and configuring the application for basic use and, as such, the knowledge contained within can be leveraged to further develop a more production-ready solution.
Credit
The above tutorial was pieced together with some information from the following sites/resources: