From: Michael Tremer Date: Tue, 7 Oct 2025 08:11:06 +0000 (+0000) Subject: graphs: Make it easier to compute custom CDEFs X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ad05c1404d376807a8280e6adb0abcd05ae777a;p=telemetry.git graphs: Make it easier to compute custom CDEFs Signed-off-by: Michael Tremer --- diff --git a/src/daemon/graphs/graph.h b/src/daemon/graphs/graph.h index 30b06b7..b6b8364 100644 --- a/src/daemon/graphs/graph.h +++ b/src/daemon/graphs/graph.h @@ -143,21 +143,23 @@ VALUE_MAXIMUM(args, field); \ } while (0) +#define COMPUTE_CDEF(args, cdef) SCRIPT(args, "CDEF:" cdef) + #define COMPUTE_SUM(args, sum, summand1, summand2) \ do { \ - SCRIPT(args, "CDEF:" sum "=" summand1 "," summand2 ",+"); \ + COMPUTE_CDEF(args, sum "=" summand1 "," summand2 ",+"); \ VALUE_ALL(args, sum); \ } while (0) #define COMPUTE_DIVIDE(args, fraction, dividend, divisor) \ do { \ - SCRIPT(args, "CDEF:" fraction "=" dividend "," TOSTRING(divisor) ",/"); \ + COMPUTE_CDEF(args, fraction "=" dividend "," TOSTRING(divisor) ",/"); \ VALUE_ALL(args, fraction); \ } while (0) #define COMPUTE_PERCENTAGE(args, field, total) \ do { \ - SCRIPT(args, "CDEF:" FIELD_PERCENT(field) "=100," field ",*," total ",/"); \ + COMPUTE_CDEF(args, FIELD_PERCENT(field) "=100," field ",*," total ",/"); \ VALUE_ALL(args, FIELD_PERCENT(field)); \ } while (0)