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);
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());
}
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)