]> git.ipfire.org Git - telemetry.git/commitdiff
graphs: Make it easier to compute custom CDEFs
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 7 Oct 2025 08:11:06 +0000 (08:11 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 7 Oct 2025 08:11:06 +0000 (08:11 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/graphs/graph.h

index 30b06b771e209cc7d6ba7a585e82d8601f190d11..b6b83647d3e9f3f8389b6efaef3e5847f13a2577 100644 (file)
                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)