I run a couple of Internet-facing servers for my website, side projects, and the like. I also have the pleasure of a home Internet connection that isn't always the best. (Don't we all!) It's useful to be able to monitor network conditions to specific servers or addresses -- usually to determine that my home connection is to blame.
SmokePing -- written by Tobi Oetiker of RRDTool notoriety -- monitors network latency and visualizes it with a number of useful graphs. There are a lot of ways you can configure SmokePing to monitor and present network latency, but it's pretty dang helpful right out of the box.
Installing and configuring SmokePing is pretty straightforward for most Linux distributions, but I had a hard time finding a good example of how to do it on FreeBSD. So, here are the steps I took to get an Apache and SmokePing stack running.
SmokePing itself is already distributed with the FreeBSD Ports Collection. It's just a matter of installing SmokePing and its dependencies:
pkg install smokeping
Add SmokePing to
SmokePing's main configuration file is
/usr/local/etc/smokeping/config. We'll need to edit this to change some basic configuration settings, as well as to add the targets that we want to monitor:
contact, and optionally
sendmail lines, and change them appropriately.
owner = jexample contact = email@example.com mailhost = mail.example.com sendmail = /usr/sbin/sendmail
You'll want to comment out the
*** Alerts *** and
*** Slaves *** sections for now:
# *** Alerts *** # to = firstname.lastname@example.org # from = email@example.com # # +someloss # type = loss # # in percent # pattern = >0%,*12*,>0%,*12*,>0% # comment = loss 3 times in a row ... # *** Slaves *** # secrets=/usr/local/etc/smokeping/smokeping_secrets # +boomer # display_name=boomer # color=0000ff # # +slave2 # display_name=another # color=00ff00
Now, find the
*** Targets *** section and set up the targets you want to monitor. Targets are listed hierarchically, with multiple plus signs denoting the depth. The example below divides our targets into "web servers" and "databases".
+ Targets menu = Targets title = Targets host = /Targets/WebServers/www-east /Targets/WebServers/www-west /Targets/Databases/db-primary /Targets/Databases/db-secondary ++ WebServers menu = Web Servers title = Web Servers host = /Targets/WebServers/www-east /Targets/WebServers/www-west +++ www-east menu = www-east title = www-east host = www-east.example.com +++ www-west menu = www-west title = www-west host = www-west.example.com ++ Databases menu = Databases title = Databases host = /Targets/Databases/db-primary /Targets/Databases/db-secondary +++ db-primary menu = Primary DB title = Primary DB host = db-primary.example.com +++ db-secondary menu = Secondary DB title = Secondary DB host = db-secondary.example.com
You don't have to arrange your targets in multiple levels. You can make it as simple as you'd like, or break it down even further.
You'll want to install Apache to serve up all of the goodness that SmokePing is generating. We'll be using
mod_cgi and Apache 2.4.
pkg install apache24
Now, add Apache to your
/usr/local/smokeping/htdocs in this example, but you can name this alias anything you'd like. You can even toss it under a subdomain with a VirtualHost.
/usr/local/etc/apache24/Includes/smokeping.conf and add the following lines to this new file:
LoadModule cgi_module libexec/apache24/mod_cgi.so Alias /smokeping /usr/local/smokeping/htdocs Require all granted AllowOverride none Options Indexes FollowSymLinks ExecCGI AddHandler cgi-script .cgi .fcgi DirectoryIndex index.html smokeping.fcgi
This loads mod_cgi and tells Apache where to look when serving up
/smokeping. It also enables
ExecCGI so that
smokeping.fcgi can be run.
DirectoryIndex tells Apache to serve up
smokeping.fcgi if it's in a directory that we're accessing. Since we've enabled
mod_cgi and turned on
ExecCGI for our SmokePing directory, Apache will run this CGI script and serve the result.
Finally, you're ready to start Apache and SmokePing. First you'll want to check the config for Apache:
service apache24 configtest
Now start them both:
service apache24 start service smokeping start
/smokeping on your server and make sure the SmokePing page loads successfully. If it does, wait 5-10 minutes, and your graphs should start coming in!
This written work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.