Basic Smokeping Setup in a Container

If you’re not familiar, smokeping is a tool that helps visualize loss and latency to a given destination. It will ping a list of hosts about 20 times every 5 minutes and then, on a web page, show a graph that displays the average latency and will also indicate any packet loss. The really handy thing is the history that it keeps. By default you get 4 graphs; a 3 hour, 30 hour, 10 day, and 360 day view. This lets you immediately spot outliers and gives you context as to the magnitude.

The goal of this effort is to get smokeping up and running on a host using docker and docker compose.

Site: https://oss.oetiker.ch/smokeping/

PreReqs and Notes

  • Assume you have access to a host that also has docker installed and working.
  • Have some IP’s or Hostnames of things you’d like to track
  • The below will run the container on port 80. If you want to put this behind TLS (you should!) you’ll need to use something like traefik (container proxy) or nginx to manage front end access.

A place to call home

For my docker containers that run “services” I like to place the configs and associated files in a common directory in /srv/<service_name>.

Create a directory to hold our smokeping setup:

1
2
sudo mkdir -p /srv/smokeping/config
sudo mkdir -p /srv/smokeping/data

Use docker-compose.yml to setup the service

It’s completely feasible to just use plain docker run cli tooling to do the below but using docker compose makes life so much easier.

Define a docker-compose.yml

1
sudo nano /srv/smokeping/docker-compose.yml

Insert the following text:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
---
version: "2.1"
services:
  smokeping:
    image: lscr.io/linuxserver/smokeping:latest
    container_name: smokeping
    hostname: some.boxonthe.net
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
    volumes:
      - /srv/smokeping/config:/config
      - /srv/smokeping/data:/data
    ports:
      - 80:80
    restart: unless-stopped

A couple of things to note here

  • Line 6: container_name: smokeping This makes the container “name” consistent so you always know what to look for when runing cli commands. Looking for ‘smokeping’ is easier than d86a52649a8a.
  • Line 7: when smokeping runs it uses the hostname to fill in text in a few places. When a docker container runs the hostname can change each time the container is updated or restarted. This makes the name consistent. It also ensures you know from where the probing is happening.
  • Line 11: feel free to modify the timezone to suit your needs, see options for timezones

Start the container

Now the container is started, it won’t do much but it proves the container can start. Bonus, the container starting will generate all the config files for us.

docker compose up

Now let the container start up and do its thing. After a minute or so the container should have started everything and have a default setup for you to play with. Open your browser and go to http://your_host and there should be something that looks similar to this

Smokeping First Run

Feel free to poke around a bit. All of the graphs will be blank because no data has been collected just yet. If you give it 20-30 mins data will start to be displayed. This is great and all but we want to ping our own hosts.

Hit ctrl-c to stop the container

Add custom targets

There should now be several files in the /srv/smokeping/config directory. Feel free to poke around in them and change anything that interests you. Probably the General file is a good place to start.

What we’re really interested in s the Targets file.

This is the default first few config lines:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
*** Targets ***

probe = FPing

menu = Top
title = Network Latency Grapher
remark = Welcome to the SmokePing website of WORKS Company. \
         Here you will learn all about the latency of our network.

+ InternetSites

menu = Internet Sites
title = Internet Sites

++ Facebook
menu = Facebook
title = Facebook
host = facebook.com

General config setup

Most smokeping config files work in a hierarchical manner. Meaning that there are multiple “levels” of config and things defined a higher levels roll down to lower levels in the tree. Config statements placed lower in the tree only affect that level and below. This can also be used to override settings from higher in the tree.

Probes

Line 3 here defines the probe to be used. In this case it is fping which is very similar to the normal ping command you are used to but operates slightly differently and makes it easy to use in tools and scripts. There are many probes that smokeping has built in. Want to graph dns response times: https://oss.oetiker.ch/smokeping/probe/DNS.en.html. Scroll down in the default Targets config and you can see there is already a DNS probe conigured as an example.

Targets

The *** Targets *** config uses + characters to denote config hierarchy. Top level items will be defined with a single + and subsequent items with ++ and ones below that with +++ and so on. Refer to Smokeping Config documentation for all the options and fun things to tweak. Scroll down to the Targets section for details on how to manage targets, how they display, what probes to use, etc..

For our purposes we are going to remove all the example config and only probe a couple hosts.

Delete the default Target configs

Delete the config for Targets. Feel free to make a backup and place it somewhere safe if you’d like to refer back to it.

Files will be recreated by the container on startup if they do not exist, so feel free to play and restart as needed
1
sudo rm /srv/smokeping/config/Targets

Insert our own targets

Edit the Targets file

1
sudo nano /srv/smokeping/config/Targets

Insert the following config

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
*** Targets ***

probe = FPing

menu = Top
title = Network Latency Grapher

+ Destinations
menu = Target Destinations

++ facebook
title = Facebook Title
host = www.facebook.com
menu = Facebook Menu

++ google
host = www.google.com

++ fark
host = www.fark.com

+ other_destinations
menu = Other Destinations

++ cisco
host = www.cisco.com

++ juniper
host = www.juniper.com

We have now created to groups of hosts to ping, the “Destinations” group and the “other_destinations” group. The names of these groups must not contain spaces, only the characters -_0-9a-zA-Z.. The menu and title statements are optional, they will be filled in with the local machine’s hostname. However we can use these statements to better describe our groups and hosts. See the image below and reference the config above to see how menu and title are used to better annotate our setup.

Smokeping Our Targets

And Run!

Now that our basic config is in place, start up the container and let it ride for 20 minutes or so. Then come back and check the graphs

1
2
3
cd /srv/smokeping
docker compose up -d
docker compose logs -f