5.0 KiB
Smokeping Guide
This guide will walk you through how to set up smokeping on a raspberry pi using docker and ubuntu server.
Install Ubuntu Server
Download Ubuntu Image
In our example we're using a pi 3, so we'll go and grab their Ubuntu install image from here. When choosing the image, I recommend using 64 bit.
Install Etcher
You can use any variety of programs for this, including something as basic as dd
, however for ease of use I recommend using etcher. Once downloaded, install the program.
Write image
Once etcher is installed, unzip the the Ubuntu Server image and use etcher to write it to an SD card. It will prompt you to type in a password, this is normal.
If the SD card was already mounted it may fail, just retry and it should work fine.
Edit pre-boot configuration files
Once etcher has finished, macos will automatically mount the boot partition of the SD card ready for use. Ubuntu server ships with two files in the boot partition to allow customisations such as network config and passwords before first boot:
These config files are only used on the first boot, modifying them after first boot will have no effect. If you want to re-apply you must re-flash the SD card or manually edit the pi's configuration files by logging in to it.
network-config
The network-config set up the network interfaces for options such as:
- DHCP
- Static IP
- Wifi Networks
For the purposes of this tutorial it is safe to leave it as standard - this will give the pi a dynamic DHCP address.
user-data
The user-data file is used for a variety of configuration items, such as setting up users, installing packages, configuring hostnames etc. For the purposes of this tutorial we are going to do the following things:
- Disable automatic password expiry for the default user
- set the hostname to smokepi
To do this, edit the user-data
config file, find the following section and modify it from:
chpasswd:
expire: false
list:
- ubuntu:ubuntu
To:
chpasswd:
expire: true
list:
- ubuntu:ubuntu
hostname: smokepi
Optionally you could change the default user from ubuntu to adam and the default password from ubuntu to password1 by changing it to this instead:
chpasswd:
expire: true
list:
- adam:password1
hostname: smokepi
First boot
Once the pi has booted, we must wait for it to stop installing updates before we can continue. To check this, run the following command:
while true; do date; ps aux | grep unattended; sleep 5; done
This will start a never-ending command that will print all processes matching "unattended" back to the console. When updates are complete, it should simply return two lines that match.
Install Docker
This section was taken from docker's own documentation available here.
Install pre-requisites
First we must install the packages that Ubuntu needs in order to configure the docker repository:
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
Add Docker GPG key
Next we must install Docker's GPG key so that your pi trusts the docker packages it is about to install:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Add Docker repositories
Now we will install the docker packages. If you installed 64 bit Ubuntu (recommended), run:
sudo add-apt-repository \
"deb [arch=arm64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
If you installed 32 bit Ubuntu, run:
sudo add-apt-repository \
"deb [arch=armhf] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
Install Docker packages
Now we must install docker itself with the following commands:
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
Add ubuntu user to docker groups
Now we must add the ubuntu user to the docker group. Doing this ensures that you can run the docker
command without prefixing it with sudo
:
usermod -aG docker ubuntu
Once this is done you will need to disconnect and reconnect your ssh connection in order for your user's group membership to be picked up.
If you changed the username in the user-data, change ubuntu
for whichever username you chose.
Test that docker is working
Finally you should check that docker is up and running by running docker ps
. Below is what the output should look like when running the command:
ubuntu@smokepi:~/ $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Clear graphs
sudo rm -rf /opt/smokeping/data/*