]> mj.ucw.cz Git - arexx.git/commitdiff
Logging to RRD and MQTT can be configured (by #define's)
authorMartin Mares <mj@ucw.cz>
Fri, 17 Apr 2020 17:20:58 +0000 (19:20 +0200)
committerMartin Mares <mj@ucw.cz>
Fri, 17 Apr 2020 17:20:58 +0000 (19:20 +0200)
README
arexxd.c

diff --git a/README b/README
index 03ad357bc46a2e2c1768c49535fcf2f72172a08f..50d9efa4cb949418ec2c1fbd5e0e2f7c893a5180 100644 (file)
--- a/README
+++ b/README
@@ -2,7 +2,7 @@
 
                            Arexx Data Logger Daemon
 
-                   (c) 2011--2018 Martin Mares <mj@ucw.cz>
+                   (c) 2011--2020 Martin Mares <mj@ucw.cz>
 
        You can use and distribute this program under the terms of GPLv2.
 
@@ -21,9 +21,11 @@ so I reverse-engineered the communication protocol and wrote my own software.
 This package contains a daemon (arexxd), which watches USB and whenever the
 data logger is connected, it downloads all data points from its memory and
 continues fetching all further measurements in real time. Also, it synchronizes
-the clock of the logger to the system time. The data points are stored in a RRD
-database (see http://oss.oetiker.ch/rrdtool/), but you can easily tweak the
-source to process the data in any way you like.
+the clock of the logger to the system time.
+
+The data points can be stored in a RRD database (see http://oss.oetiker.ch/rrdtool/)
+or sent to InfluxDB (this is configured rather crudely in the source code).
+You can easily tweak the source to process the data in any way you like.
 
 This program is not supported or endorsed by AREXX in any way. Also, there is
 no warranty on what it does or does not. However, if you have any bug reports
index 1bde4a26014be519c73ac4f506797038c9ef12b4..df1877b627ad99de529a484ebbe7aea5d5e1d991 100644 (file)
--- a/arexxd.c
+++ b/arexxd.c
@@ -1,7 +1,7 @@
 /*
  *     Linux Interfece for Arexx Data Loggers
  *
- *     (c) 2011-2018 Martin Mares <mj@ucw.cz>
+ *     (c) 2011-2020 Martin Mares <mj@ucw.cz>
  */
 
 #include <stdio.h>
@@ -34,6 +34,9 @@
 #define MAX_FUTURE_TIME 300
 #define IGNORE_UNKNOWN_SENSORS
 
+#undef LOG_TO_RRD
+#undef LOG_TO_MQTT
+
 typedef unsigned char byte;
 typedef unsigned int uint;
 static libusb_context *usb_ctxt;
@@ -104,6 +107,8 @@ static void log_pkt(char *fmt, ...)
 
 /*** MQTT interface ***/
 
+#ifdef LOG_TO_MQTT
+
 #include <mosquitto.h>
 
 static struct mosquitto *mosq;
@@ -155,8 +160,12 @@ static void mqtt_point(time_t t, const char *name, double val, char *unit UNUSED
        mqtt_publish(topic, "%.3f %lld", val, (long long) t);
 }
 
+#endif
+
 /*** RRD interface ***/
 
+#ifdef LOG_TO_RRD
+
 #include <rrd.h>
 
 #define MAX_ARGS 20
@@ -231,6 +240,8 @@ static void rrd_point(time_t t, const char *name, double val, char *unit)
        }
 }
 
+#endif
+
 /*** Transforms ***/
 
 #define TIME_OFFSET 946681200          // Timestamp of 2000-01-01 00:00:00
@@ -298,8 +309,12 @@ static void cooked_point(time_t t, uint id, double val, char *unit, int q)
        }
 
        data_point_counter++;
+#ifdef LOG_TO_RRD
        rrd_point(t, name, val2, unit);
+#endif
+#ifdef LOG_TO_MQTT
        mqtt_point(t, name, val2, unit);
+#endif
 }
 
 static void raw_point(uint t, uint id, int raw, int q)
@@ -763,7 +778,9 @@ int main(int argc, char **argv)
                use_syslog = 1;
        }
 
+#ifdef LOG_TO_MQTT
        mqtt_init();
+#endif
 
        struct sigaction sa = { .sa_handler = sigterm_handler };
        sigaction(SIGTERM, &sa, NULL);