Inhaltsverzeichnis

vzlogger Installation (en)

Repository

Our repository: https://github.com/volkszaehler/vzlogger

Actually vzlogger and sometimes the libraries are only provided by sourcecode. They have to be compiled before use. Select a working directory your user has writing permissions. For example the home directory:

cd ~

The most experience is collected from Debian and other Distributions close (Ubuntu, Raspian). The following guide is based on Debian „Bullseye“ in April of 2022. Specific instructions for older Versions can be found in the history of this site.

Prerequisites for compiling vzlogger

Please note that a full configured vzlogger requires besides gcc (4.7 or higher) and glibc, these libraries to compile successfully:

Tools

Required Libraries

Debian packages

On Debian based distributions, most of these dependencies can easily be installed with: (as root, consider running „apt-get update“ first)

sudo apt-get install build-essential git cmake pkg-config subversion libcurl4-openssl-dev libgnutls28-dev libsasl2-dev uuid-dev libtool libssl-dev libgcrypt20-dev libmicrohttpd-dev libltdl-dev libjson-c-dev libleptonica-dev libmosquitto-dev libunistring-dev dh-autoreconf

Build by script

Vzlogger provides a shell script for download, build and install of the modules issued only as sourcecode.

git clone https://github.com/volkszaehler/vzlogger.git
cd vzlogger
./install.sh

The script supports also build of one single module. See the comments in the script for details.

Daemon

At this point a daemon-service should be prepared to run vzlogger in backgroung. Details down below.

Update

If a update is necessary follow these steps:

sudo systemctl stop vzlogger 
cd vzlogger
git pull
./install.sh vzlogger
sudo systemctl start vzlogger

The based SML Library may (before) updated by:

cd vzlogger/libs/libsml
git pull
cd ../..
./install.sh libsml

Build by hand

In cases the script does not fit the conditions.

​Only for experienced users! Follow build by script instead.

Building libsml

Debian provides a paket libsml-dev, but it's not well maintained and too old for our needs.

git clone https://github.com/volkszaehler/libsml.git
cd libsml
sudo make

Note that libsml does not include a 'make install' target.

You can manually install it into your system by copying the following files and directories

sudo cp sml/lib/libsml.* /usr/lib/
sudo cp -R sml/include/* /usr/include/
sudo cp sml.pc /usr/lib/pkgconfig/

Go back to your starting directory:

cd ..

Building vzlogger

git clone https://github.com/volkszaehler/vzlogger.git
cd vzlogger
mkdir build
cd build
cmake -DBUILD_TEST=off ..
make
sudo make install

Go back to your starting directory:

cd ../..
Build as Debian-paket

The vzlogger repository contains code to build a „clean“ paket for Debian.

git clone https://github.com/volkszaehler/vzlogger.git 
cd vzlogger 
apt build-dep ./ 
apt install devscripts 
debuild

Building OMS

OMS requires openssl and libmbus >=0.8.0 from e.g. https://github.com/rscada/libmbus.git (installation is easy:)

git clone https://github.com/rscada/libmbus.git
cd libmbus
sudo ./build.sh
sudo make install

Go back to your starting directory:

cd ..

Daemon

At this point a daemon-service should be prepared to run vzlogger in backgroung. Details down below.

Update vzlogger

If a update is necessary follow these steps:

cd vzlogger
git pull
cd build
cmake -DBUILD_TEST=off ​..
make
sudo systemctl stop vzlogger
sudo make install
sudo systemctl start vzlogger

Systemd start script

Systemd is used to install and execute services in background (daemon).

The installscript asks you for installing the systemd unit file for you. If your computer uses systemd (since Debian-Jessie) you may answer yes.

If you want to copy and edit it by yourself you find a template under: ./etc/vzlogger.service

sudo cp ./etc/vzlogger.service /etc/systemd/system/vzlogger.service
Please make sure that both paths to the binary (vzlogger) and its configuration file (vzlogger.conf) are correct.

You can start, stop or verify vzloggers status using the common systemctl command:

sudo systemctl start vzlogger
systemctl status vzlogger
sudo systemctl stop vzlogger
You need a working configuration at this point! Else vzlogger will be closed and systemd generates failures.

If you are satisfied and want to have vzlogger permanently startet as a service everytime your machine boots, just enable it:

sudo systemctl enable vzlogger

Run vzlogger with different user

Elevated privileges for vzlogger binary

sudo setcap 'cap_sys_nice=eip' /usr/local/bin/vzlogger
On Raspberry might still be problems with configuration of GPIOs. Earlier export in /etc/rc.local solves the problem.

Add Daemon-User

Add a user without home-directory and generate password.

sudo useradd -M vzlogger
sudo passwd vzlogger

Add the user to the follwing groups:

sudo usermod -aG gpio vzlogger
sudo usermod -aG dialout vzlogger
sudo usermod -aG staff vzlogger

For the logfile generate a sub-directory with adequate rights.

sudo mkdir /var/log/vzlogger
sudo chgrp staff /var/log/vzlogger
sudo chmod g+w /var/log/vzlogger

adapt vzlogger.conf

The new location oft logfile has to be configured accordingly. /etc/vzlogger.conf:

"log" : "/var/log/vzlogger/vzlogger.log",

adapt Systemd startscript

Last change is to promote the new user in systemd startscript (see chapter above).

Under [Service] add the following line:

User=vzlogger

Systemd need to be restartet to activate the change:

sudo systemctl daemon-reload

Use-sase

This adaption is of particular interest in combination with meter-protocol „exec“. Vzlogger doesn't have to be recompiled and the actions started by „exec“ run with lower user-privilges.

Special hints

debian package

a debian package can be generated using:

cpack -G DEB

Cross compiling

cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/toolchainfile /path/to/vzlogger_sources