Set up your own lab environment with KVM, Qemu, and Libvirt
Setting up the Systems
When you get the VMs up and running, the next step is to install the applications that will run on three virtual systems: InfluxDB [2], collectd, and Grafana.
The InfluxDB packages are not part of the official Ubuntu repositories; however, a third-party repository contains everything we need. Execute the commands in Listing 9 as root on the influx01 VM.
Listing 9
Installing InfluxDB
# curl -sL https://repos.influxdata.com/influxdb.key | apt-key add - # source /etc/lsb-release # echo "deb https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | tee /etc/apt/sources.list.d/influxdb.list # apt-get update # apt-get install influxdb # cd /etc/influxdb/ # wget http://hoebel.net/downloads/articles/influxdb.conf # mkdir /usr/share/collectd # cd /usr/share/collectd/ # wget https://raw.githubusercontent.com/collectd/collectd/master/src/types.db # systemctl restart influxdb
Now check if the InfluxDB application is running:
ps aux |grep influx
The next step is to log into the collectd01 system and set up the collectd daemon [3]. Collectd collects metrics of the local system and sends them to InfluxDB for permanent storage. Listing 10 shows the steps for installing the manic collectd collecting service on the collectd01
test system. Check to see if the daemon is actually running:
ps aux | grep collectd
If it isn't running, stop all collectd processes and relaunch the service.
Listing 10
Installing Collectd
# apt-get update # apt-get install collectd collectd-utils # cd /etc/collectd/ # wget http://hoebel.net/downloads/articles/collectd.conf # systemctl restart collectd
After a few minutes of run time, the time-series database fills InfluxDB with metrics from the collectd01 test system. Check the status by running the influx
command on the InfluxDB VM and listing all databases with show databases
.
Use use collectd
and show measurements
to show which value categories ended up in the database. The quit
command takes you back to the command line.
The virtual laboratory now collects metrics from one of the test systems and stores them in a database on another VM via the virtual network. The last step is to add visualization using Grafana [4].
Open a command line on the grafana01 test system and install Grafana (Listing 11). Line 1 sets up a software repository for Debian systems. (The system is Ubuntu, but Grafana developers have deliberately kept their package repository simple and have taken advantage of the fact that the package management works in the same way under Ubuntu and Debian.)
Listing 11
Installing Grafana
# echo "deb https://packagecloud.io/grafana/stable/debian jessie main" | tee /etc/apt/sources.list.d/grafana.list # curl https://packagecloud.io/gpg.key | sudo apt-key add - # apt-get update # apt-get install grafana # systemctl start grafana-server
After you launch Grafana, the service listens on port 3000. Open the http://172.100.100.31:3000 URL in a web browser, and you'll see a welcome to the login screen. Sign up as admin with the password admin and click on the Add data source link. In the Name field, enter the InfluxDB value and select the same value in the Type drop-down menu.
For URL, enter the http://172.100.100.21:8086 character string – Grafana will later reach InfluxDB under this address. Skip the configuration fields for Http Auth and, under InfluxDB Details, enter the name collectd in the Database field. Now press the green Add button and then Save & Test. Figure 8 shows the complete configuration.

You'll find a Grafana dashboard prepared for this configuration at my website [5]. Download the configuration file and click on the Grafana icon in the top left in Grafana. The icon opens a menubar where you select Dashboards | Import. In the next dialog, install the recently downloaded JSON file using the Upload .json File button. Don't forget to select the correct data source InfluxDB before clicking Import.
Next, Grafana guides you to the recently imported dashboard. Enter the collectd01 value under Host in the top left, or simply go to the link shown in Listing 12. Figure 9 shows the visualized data. The prefabricated dashboard displays all sorts of processed metrics for the collectd01 test system.
Listing 12
Point Grafana to the Data
http://172.100.100.31:3000/dashboard/db/server-operating-system-metrics?refresh=1m&orgId=1&var-host=collectd01&var-interval=$__auto_interval

Conclusions
Creating a virtual test lab on your home computer requires less work than you might expect. Pay attention, take your time, and remain patient; you will very soon discover that the techniques described in this article will let you quickly configure and model complex test scenarios.
Infos
- Libvirt: https://libvirt.org/
- Official InfluxDB website: https://www.influxdata.com
- Collectd: https://collectd.org
- Grafana: https://grafana.com
- Grafana dashboard for the virtual lab: http://hoebel.net/downloads/articles/LinuxUser-Grafana-Dashboard.json
« Previous 1 2
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Direct Download
Read full article as PDF:
Price $2.95
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Find SysAdmin Jobs
News
-
KDE Plasma 5.27 Beta is Ready for Testing
The latest beta iteration of the KDE Plasma desktop is now available and includes some important additions and fixes.
-
Netrunner OS 23 Is Now Available
The latest version of this Linux distribution is now based on Debian Bullseye and is ready for installation and finally hits the KDE 5.20 branch of the desktop.
-
New Linux Distribution Built for Gamers
With a Gnome desktop that offers different layouts and a custom kernel, PikaOS is a great option for gamers of all types.
-
System76 Beefs Up Popular Pangolin Laptop
The darling of open-source-powered laptops and desktops will soon drop a new AMD Ryzen 7-powered version of their popular Pangolin laptop.
-
Nobara Project Is a Modified Version of Fedora with User-Friendly Fixes
If you're looking for a version of Fedora that includes third-party and proprietary packages, look no further than the Nobara Project.
-
Gnome 44 Now Has a Release Date
Gnome 44 will be officially released on March 22, 2023.
-
Nitrux 2.6 Available with Kernel 6.1 and a Major Change
The developers of Nitrux have officially released version 2.6 of their Linux distribution with plenty of new features to excite users.
-
Vanilla OS Initial Release Is Now Available
A stock GNOME experience with on-demand immutability finally sees its first production release.
-
Critical Linux Vulnerability Found to Impact SMB Servers
A Linux vulnerability with a CVSS score of 10 has been found to affect SMB servers and can lead to remote code execution.
-
Linux Mint 21.1 Now Available with Plenty of Look and Feel Changes
Vera has arrived and although it is still using kernel 5.15, there are plenty of improvements sure to please everyone.