Installing LibreNMS on Docker

As its website explains, LibreNMS is “a fully featured network monitoring system that provides a wealth of features and device support”. It can be used to monitor servers and services so make sure they are functioning as intended.

Setting up LibreNMS

To set LibreNMS up, we will follow the official guide, correcting some of the commands and installing some additional software.

First, we will download the latest LibreNMS code from its GitHub repository, then we will extract the Docker-related files and delete the rest of the files:

mkdir ./librenms-temp
cd ./librenms-temp
wget https://github.com/librenms/docker/archive/refs/heads/master.zip
unzip master.zip
cd ..
cp -r ./librenms-temp/docker-master/examples/compose ./librenms
rm -rf ./librenms-temp
cd librenms

We can now optionally edit the .env file (e.g. to change the default database password):

nano .env

Now let’s launch the containers of LiberNMS:

sudo docker compose -f compose.yml up -d

As soon as all the containers are up, visit http://localhost:8000/ (or replace localhost with your server’s IP) and initialise LibreNMS by creating an admin account.

Installing Nagios plugins on LibreNMS Docker

After completing the LibreNMS setup, we can shut it down temporarily to install the Nagios plugins. To shut LibreNMS down, we can turn off its containers:

sudo docker compose -f compose.yml down

Let’s now install nagios-plugins that will allow us to create some service checks inside LiberNMS. To do so, we will create a temporal Ubuntu container (named tmp) to install nagios-plugins copy the binaries we need to LibreNMS files and delete them:

sudo docker run --name tmp -v $(pwd)/librenms:/opt/librenms -i -t ubuntu bash
apt update
apt install nagios-plugins -y
cp -P /usr/lib/nagios/plugins/* /opt/librenms/monitoring-plugins/
exit
sudo docker rm tmp

Then, we can start LibreNMS again:

sudo docker compose -f compose.yml up -d

The plugins will now be available inside the “Add Service” menu, under “Type”.

Setting up Website checks

Now that Nagios plugins are installed, we can use the Nagios check_http plugin to monitor the status of our websites.

Certificate Check

Let’s create a service to check our website certificate.

  • Click + Add Service from the menu
  • Give a name to the service
  • Select a device from the list (maybe the server hosting the website)
  • Select http as a Check Type
  • Input the domain of your website inside the Remote Host input
  • Input the parameters --sni -S -p 443 -C 30,14 -t 20 inside the Parameters input
  • Click Add Service

This will check the certificate of the website and generate a critical alert if it is about to expire in less than 14 days or generate a warning if it is about to expire in less than 30 days.

Website Check (HTTP/HTTPS)

Let’s create a service to check our website status over HTTP or HTTPS.

  • Click + Add Service from the menu
  • Give a name to the service
  • Select a device from the list (maybe the server hosting the website)
  • Select http as a Check Type
  • Input the domain of your website inside the Remote Host input
  • Input the parameters inside the Parameters input
    • to check an HTTP website insert the: -E -p 80 -t 20
    • to check an HTTPS website insert the: --sni -E -S -p 443 -t 20
  • Click Add Service

This will check the website and generate an alert in case it throws an error or if the website is unresponsive.

Sum up

LibreMNS is an easy to setup tool that can assist you in monitoring your servers and services. Plus, it can be easily set up using Docker. You can give it a try! 😊

Installing Portainer on Docker

I found Portainer to be just what I needed to manage the containers of my small Docker servers. You can install it easily as a container running on the same Docker server that you want it to manage.

Setting Portainer up

To install it, you first need to create a volume so that it can store your accounts and preferences:

sudo docker volume create portainer_data

Then you can deploy the container using the official Portainer image (please note that in the following command, I removed the -p 8000:8000 port mapping as I will only be using the HTTPS protocol to connect to it):

sudo docker run -d -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest

Now, you can visit though https (under port 9443) the deployed Portainer app to create an admin account. For example, if your server is located at 10.10.1.30, you can access Portainer at:

https://10.10.1.30:9443/

Please note that your browser will not trust the certificate, thus you will have to “Accept the risks” and proceed.

Updating Portainer

Updating Portainer to the latest version is relatively simple. First, you will have to pull the latest version of the container using:

 sudo docker pull portainer/portainer-ce:latest

Then you can just recreate the container without deleting the volume holding your configuration:

sudo docker stop portainer
sudo docker rm portainer
sudo docker run -d -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest

As simple as that! 🙂

Installing Gogs Git Server on Raspberry Pi

Git is a must-have utility for programmers. It allows you to track code changes and easily share your code with others enabling remote collaboration. Online git services like GitHub, GitLab, and Bitbucket are nowadays accessible for everyone, though sometimes the need to self-host a private service arises.

Gogs is an open-source git server, light enough to run on a Raspberry Pi. It is written in Go Lang and provides pre-compiled binaries for arm architectures.

In this tutorial, we will install Gogs on a Raspberry Pi 2. So, first, connect to your Raspberry, and let’s start!

Update your system

To start with, update our system and install any missing dependencies.

sudo apt update
sudo apt install wget unzip git -y

Prepare for installation

We will create a special user called git to operate the Gogs server. The following command will create the user and disable his password:

sudo adduser --system --shell /bin/bash --gecos "User for managing of gogs server" --group --disabled-password --home /home/git git

The next thing we will have to do is to download the pre-compiled Gogs package. Check the latest versions available at https://dl.gogs.io/. At the time of writing this report the latest version is 0.12.3 so we downloaded the gogs_0.12.3_linux_armv7.zip package (armv7architecture is compatible with Raspberry Pi 2, 3, and 4).

sudo su -c 'su git -c "wget https://dl.gogs.io/0.12.3/gogs_0.12.3_linux_armv7.zip -O ~/gogs_download.zip"'

After the download completes, unzip the package and then you may delete it.

sudo su -c 'su git -c "unzip ~/gogs_download.zip -d ~/"'
sudo su -c 'su git -c "rm ~/gogs_download.zip"'

Start the server

Now let’s setup the Gogs service to manage the server. Download the service script from the Gogs repo:

sudo wget https://raw.githubusercontent.com/gogs/gogs/main/scripts/systemd/gogs.service -O /lib/systemd/system/gogs.service

And then, enable the service and run it.

sudo systemctl enable gogs
sudo service gogs start

Follow the web installer

Now browse to the installation located at http://<your-raspbery-ip>:3000/install and complete the installation steps.