diff --git a/Dockerfile b/Dockerfile index 4c8731e0..5ac3d491 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,9 @@ -ARG DEBIAN_VERSION=buster +ARG DEBIAN_VERSION=buster-slim + +############################ +# STEP 1 build executable binary +############################ + FROM debian:$DEBIAN_VERSION as builder RUN apt-get update && apt-get install -y \ @@ -38,6 +43,11 @@ RUN cmake -DBUILD_TEST=off \ && make \ && make install + +############################# +## STEP 2 build a small image +############################# + FROM debian:$DEBIAN_VERSION LABEL Description="vzlogger" @@ -66,7 +76,4 @@ COPY --from=builder /usr/local/lib/libmbus.so* /usr/local/lib/ RUN useradd -M -G dialout vz USER vz -# Setup volume -VOLUME ["/cfg"] - CMD ["vzlogger", "--foreground"] diff --git a/README.md b/README.md index c30559ed..0941f24a 100644 --- a/README.md +++ b/README.md @@ -12,30 +12,11 @@ Installation --------------- To install, follow the detailed installation instructions at http://wiki.volkszaehler.org/software/controller/vzlogger/installation_cpp-version -If you're impatient you can quickstart using (Debian Wheezy): +If you're impatient you can quickstart using (Debian Bullseye or Ubuntu 18.04 LTS): sudo apt-get install build-essential git-core cmake pkg-config subversion libcurl3-dev \ libgnutls-dev libsasl2-dev uuid-dev uuid-runtime libtool dh-autoreconf libunistring-dev -For Debian Jessie, be sure to add: - - sudo apt-get install libgcrypt20-dev - -For Debian Stretch, use: - - sudo apt-get install git cmake autoconf libtool uuid-dev libcurl4-openssl-dev libssl-dev \ - libgnutls28-dev libgcrypt20-dev libmicrohttpd-dev libsasl2-dev libunistring-dev - -For Debian Buster, use: - - sudo apt-get install git cmake autoconf libtool uuid-dev libcurl4-openssl-dev libssl-dev \ - libgnutls28-dev libgcrypt20-dev libmicrohttpd-dev libsasl2-dev libunistring-dev build-essential - -Ubuntu 18.04 LTS (bionic) needs an additional: - - sudo apt-get install libunistring-dev -(this might be needed on others now as well as we link unconditionally against libunistring) - If you want to use MQTT support: sudo apt-get install libmosquitto-dev diff --git a/debian/vzlogger.manpages b/debian/vzlogger.manpages deleted file mode 100644 index f7e7cf56..00000000 --- a/debian/vzlogger.manpages +++ /dev/null @@ -1 +0,0 @@ -docs/vzlogger.1 diff --git a/docs/vzlogger.1 b/docs/vzlogger.1 deleted file mode 100644 index 764566c2..00000000 --- a/docs/vzlogger.1 +++ /dev/null @@ -1,79 +0,0 @@ -.\" Hey, EMACS: -*- nroff -*- -.\" First parameter, NAME, should be all caps -.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection -.\" other parameters are allowed: see man(7), man(1) -.TH VZLOGGER 1 "June 12, 2011" -.\" Please adjust this date whenever revising the manpage. -.\" -.\" Some roff macros, for reference: -.\" .nh disable hyphenation -.\" .hy enable hyphenation -.\" .ad l left justify -.\" .ad b justify to both left and right margins -.\" .nf disable filling -.\" .fi enable filling -.\" .br insert line break -.\" .sp insert n+1 empty lines -.\" for manpage-specific macros, see man(7) -.SH NAME -vzlogger \- program for logging measurements to a volkszaehler.org middelware -.SH SYNOPSIS -\fBvzlogger\fP [ options ] -.SH DESCRIPTION -\fBvzlogger\fP... -.TP -\fB*\fR is a tiny shell tool to log measurements of a wide variety of smartmeters, sensors & protocols against the volkszaehler.org middleware. -.TP -\fB*\fR can run as a daemon or can be invoked periodically by cron. -.TP -\fB*\fR includes a tiny onboard httpd to serve realtime readings to the ajax web frontend. -.TP -\fB*\fR is written in pure ansi c and should run on most embedded devices. -.SH OPTIONS -These programs follow the usual GNU command line syntax, with long -options starting with two dashes (`-'). -A summary of options is included below. -For a complete description, see the Info files. - -.TP -\fB\-c, \-\-config\fR -config file with channel \-> uuid mapping -.TP -\fB\-d, \-\-daemon\fR -run as daemon -.TP -\fB\-l, \-\-local\fR -activate local interface (tiny webserver) -.TP -\fB\-p, \-\-local\-port\fR -TCP port for local interface -.TP -\fB\-h, \-\-help\fR -show summary of options -.TP -\fB\-v, \-\-verbose\fR -enable verbose output -.TP -\fB\-V, \-\-version\fR -show version - -.SH PROTOCOLS -Following protocol types are supported: -.TP -\fB1wire\fR -Dallas 1\-Wire sensors (via OWFS) -.TP -\fBobis\fR -Plaintext OBIS -.TP -\fBrandom\fR -Random walk -.TP -\fBrawS0\fR -S0 on RS232 - -.SH BUGS -Currenty there are no known bugs. -Please report bugs to http://bugs.volkszaehler.org -.SH SEE ALSO -vzlogger is documented in more detail on the wiki page: http://wiki.volkszaehler.org/software/controller/vzlogger diff --git a/etc/vzlogger.conf b/etc/vzlogger.conf index 8ac60724..f30363e2 100644 --- a/etc/vzlogger.conf +++ b/etc/vzlogger.conf @@ -55,7 +55,6 @@ "timestamp": false // optional whether to include a timestamp in the payload }, - // Meter configuration "meters": [ { diff --git a/include/Config_Options.hpp b/include/Config_Options.hpp index 8277bb7f..ce7b906d 100644 --- a/include/Config_Options.hpp +++ b/include/Config_Options.hpp @@ -79,6 +79,8 @@ class Config_Options { bool doRegistration() const { return _doRegistration; } + bool haveTimeMachine() const { return _time_machine; } + // setter void config(const std::string &v) { _config = v; } void log(const std::string &v) { _log = v; } @@ -95,6 +97,8 @@ class Config_Options { void doRegistration(const bool v) { _doRegistration = v; } + void haveTimeMachine(const bool v) { _time_machine = v; } + PushDataServer *pushDataServer() const { return _pds; } private: @@ -114,6 +118,7 @@ class Config_Options { int _local : 1; // enable local interface int _foreground : 1; // don't daemonize int _doRegistration : 1; // FIXME + int _time_machine : 1; // accept readings from before smart-metering existed }; /** diff --git a/include/api/InfluxDB.hpp b/include/api/InfluxDB.hpp index ca5e57c0..7f8ae294 100644 --- a/include/api/InfluxDB.hpp +++ b/include/api/InfluxDB.hpp @@ -57,6 +57,7 @@ class InfluxDB : public ApiIF { std::string _host; std::string _username; std::string _token; + struct curl_slist *_token_header; std::string _organization; std::string _password; std::string _database; diff --git a/src/Config_Options.cpp b/src/Config_Options.cpp index cd456a78..b14d6a60 100644 --- a/src/Config_Options.cpp +++ b/src/Config_Options.cpp @@ -41,13 +41,15 @@ static const char *option_type_str[] = {"null", "boolean", "double", "int", Config_Options::Config_Options() : _config("/etc/vzlogger.conf"), _log(""), _pds(0), _port(8080), _verbosity(0), - _comet_timeout(30), _buffer_length(-1), _retry_pause(15), _local(false), _foreground(false) { + _comet_timeout(30), _buffer_length(-1), _retry_pause(15), _local(false), _foreground(false), + _time_machine(false) { _logfd = NULL; } Config_Options::Config_Options(const std::string filename) : _config(filename), _log(""), _pds(0), _port(8080), _verbosity(0), _comet_timeout(30), - _buffer_length(-1), _retry_pause(15), _local(false), _foreground(false) { + _buffer_length(-1), _retry_pause(15), _local(false), _foreground(false), + _time_machine(false) { _logfd = NULL; } @@ -178,7 +180,9 @@ void Config_Options::config_parse(MapContainer &mappings) { "mqtt"); } #endif - else { + else if ((strcmp(key, "i_have_a_time_machine") == 0) && type == json_type_boolean) { + _time_machine = json_object_get_boolean(value); + } else { print(log_alert, "Ignoring invalid field or type: %s=%s (%s)", NULL, key, json_object_get_string(value), option_type_str[type]); } diff --git a/src/api/InfluxDB.cpp b/src/api/InfluxDB.cpp index 24671531..227aa7a8 100644 --- a/src/api/InfluxDB.cpp +++ b/src/api/InfluxDB.cpp @@ -57,9 +57,12 @@ vz::api::InfluxDB::InfluxDB(const Channel::Ptr &ch, const std::list