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/
- 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.
For my docker containers that run “services” I like to place the configs and associated files in a common
directory in /srv/<service_name>
.
|
|
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.
|
|
Insert the following text:
|
|
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 thand86a52649a8a
. - 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
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
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
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:
|
|
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.
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.
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 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
|
|
Edit the Targets
file
|
|
Insert the following config
|
|
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.
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
|
|