]> mj.ucw.cz Git - arexx.git/commitdiff
RRD now keeps also 1-hour minima and maxima
authorMartin Mares <mj@ucw.cz>
Tue, 27 Dec 2011 18:28:52 +0000 (19:28 +0100)
committerMartin Mares <mj@ucw.cz>
Tue, 27 Dec 2011 18:28:52 +0000 (19:28 +0100)
arexxd.c

index 68e08d3a65bdfa8db27b79ea619088db3343f7cc..faedc5eb09a96b4527905398ee3dc09dc37d575b 100644 (file)
--- a/arexxd.c
+++ b/arexxd.c
@@ -112,7 +112,7 @@ static void arg_push(const char *fmt, ...)
        arg_pos += len;
 }
 
-static void rrd_point(time_t t, int id, double val)
+static void rrd_point(time_t t, int id, double val, char *unit)
 {
        char rr_name[256];
        snprintf(rr_name, sizeof(rr_name), "sensor-%d.rrd", id);
@@ -127,9 +127,16 @@ static void rrd_point(time_t t, int id, double val)
                arg_push("%d", (int) time(NULL) - 28*86400);
                arg_push("--step");
                arg_push("60");
-               arg_push("DS:temp:GAUGE:300:0:10000");          // Anything over 10 kW is considered a ghost
+               if (!strcmp(unit, "%RH"))
+                       arg_push("DS:rh:GAUGE:300:0:100");
+               else if (!strcmp(unit, "ppm"))
+                       arg_push("DS:ppm:GAUGE:300:0:1000000");
+               else
+                       arg_push("DS:temp:GAUGE:300:-200:200");
                arg_push("RRA:AVERAGE:0.25:1:20160");           // Last 14 days with full resolution
                arg_push("RRA:AVERAGE:0.25:60:88800");          // Last 10 years with 1h resolution
+               arg_push("RRA:MIN:0.25:60:88800");              // including minima and maxima
+               arg_push("RRA:MAX:0.25:60:88800");
                rrd_create(arg_cnt, arg_ptr);
                if (rrd_test_error()) {
                        log_error("rrd_create on %s failed: %s", rr_name, rrd_get_error());
@@ -162,7 +169,7 @@ static void cooked_point(time_t t, int id, double val, char *unit, int q)
        }
 
        data_point_counter++;
-       rrd_point(t, id, val);
+       rrd_point(t, id, val, unit);
 }
 
 static void raw_point(int t, int id, int raw, int q)