How to Setup a SmokePing Server
SmokePing is a latency measurement tool that will test, store, and display (with pretty graphs) latency and packet lost between your server and another (or external service).
Prerequisites
- More info can be found here: https://oss.oetiker.ch/smokeping/
- A base install of Ubuntu 20.04 LTS with a static IP address
- When editing a file with Nano, to save your changes to do the following:
- Ctrl+X to Exit
- Y to save the edits currently stored in the buffer
- Enter to write to the current file name
Installation
SmokePing is in the default Ubuntu repositories, to install run the following command
sudo apt update && sudo apt install smokeping -y
This will automatically install all dependency packages such as Apache2, fping, etc… Once installed, enable the cgi and rewrite mods in Apache2
sudo a2enmod cgi rewrite
Restart Apache2 to enable the changes
sudo systemctl restart apache2.service
Configuration
Next, create a html redirect so you don’t have to use https://ipaddress/smokeping/smokeping.cfg (default url)
sudo mv /var/www/html/index.html /var/www/html/index.html.old && sudo nano /var/www/html/index.html
Add the following to the index.html file
<html> <head> <meta http-equiv="refresh" content="0; url=/smokeping/smokeping.cgi" /> </head> <body></body> </html>
Save the changes by pressing Ctrl+X, Y for Yes, and Enter to select the file name to write (by default is the file we have opened)
Edit the /etc/smokeping/config.d/General file and change the owner and contact fields. Also, change cgiurl to the DNS name
*** General *** owner = COMPANY contact = tech@domain.org mailhost = my.mail.host # NOTE: do not put the Image Cache below cgi-bin # since all files under cgi-bin will be executed ... this is not # good for images. cgiurl = https://smokeping.domain.org/smokeping.cgi # specify this to get syslog logging syslogfacility = local0 # each probe is now run in its own process # disable this to revert to the old behaviour # concurrentprobes = no @include /etc/smokeping/config.d/pathnames
Save the changes by pressing Ctrl+X, Y for Yes, and Enter to select the file name to write (by default is the file we have opened)
Edit the /etc/smokeping/config.d/pathnames file and comment out the sendmail line
sudo nano /etc/smokeping/config.d/pathnames
#sendmail = /usr/sbin/sendmail imgcache = /var/cache/smokeping/images imgurl = ../smokeping/images datadir = /var/lib/smokeping piddir = /var/run/smokeping smokemail = /etc/smokeping/smokemail tmail = /etc/smokeping/tmail dyndir = /var/lib/smokeping/__cgi
Save the changes by pressing Ctrl+X, Y for Yes, and Enter to select the file name to write (by default is the file we have opened)
Next, since SmokePing will be accessible outside of the network, we need to secure the installation by creating a username/password. First make a new directory called passwd under /etc/apache2
sudo mkdir /etc/apache2/passwd
Next, create the password file with a username. Once you press enter, you’ll be asked to create a password
sudo htpasswd -c /etc/apache2/passwd/passwords administrator
Now modify the /etc/apache2/conf-available/smokeping.conf file. The file looks like this by default:
ScriptAlias /smokeping/smokeping.cgi /usr/lib/cgi-bin/smokeping.cgi Alias /smokeping /usr/share/smokeping/www <Directory "/usr/share/smokeping/www"> Options FollowSymLinks Require all granted </Directory>
Change the file to look like this:
ScriptAlias /smokeping/smokeping.cgi /usr/lib/cgi-bin/smokeping.cgi Alias /smokeping /usr/share/smokeping/www <Directory "/usr/share/smokeping/www"> Options FollowSymLinks AuthType Basic AuthName "Smokeping" AuthBasicProvider file AuthUserFile /etc/apache2/passwd/passwords Require valid-user </Directory>
Save the changes by pressing Ctrl+X, Y for Yes, and Enter to select the file name to write (by default is the file we have opened)
Restart Apache2 to enable the changes and test authentication
sudo systemctl restart apache2.service
Adding Hosts
To add a host to be monitored, edit the /etc/smokeping/config.d/Targets file
sudo nano /etc/smokeping/config.d/Targets
The file broken down with menus, separated with a +. Each new menu item starts with a + and every entry under that menu item starts with a ++.
Once your host are added, restart the SmokePing service to begin monitoring
sudo /etc/init.d/smokeping restart
You can add any host that is pingable. I will often add Google, Cloudflare, and CenturyLink DNS servers to get a base line and ensure that my outgoing circuit is not the cause of any latency or packet loss