]> git.ipfire.org Git - telemetry.git/commitdiff
graphs: Split BYTES into two macros
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 3 Apr 2026 14:14:38 +0000 (14:14 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 3 Apr 2026 14:14:38 +0000 (14:14 +0000)
The preprocessor cannot split things as we would need although it
sometimes works in a few places.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/graphs/graph.h
src/daemon/graphs/unbound-memory-usage.c

index cd8d2542b88617d5dba40f380383eea804cd6dc5..09c3a8edda1923e907cee7d6a42953dd2d3dd91b 100644 (file)
@@ -75,7 +75,8 @@ typedef enum flags {
 #define SECONDS_HIGHRES        "%%14.2lf%%ss"
 #define SECONDS         "%%15.2lfs"
 
-#define BYTES                  "%%12.2lf%%s%s", _("B")
+#define BYTES                  "%%13.2lf %%s%s"
+#define BYTES_UNIT             _("B")
 
 // Temperatures
 #define KELVIN                 "%%14.2lf K"
@@ -196,7 +197,7 @@ static inline int __DRAW(td_args* args, const char* what, const char* field,
 #define PRINT_EMPTY_LABEL(args)                                                        SCRIPT(args, "COMMENT:                                ")
 #define PRINT_NOTHING(args)                                                            SCRIPT(args, "COMMENT:                ")
 #define PRINT(args, field, object, format, ...) \
-       SCRIPT(args, "GPRINT:" FIELD ":" format, FIELD_AND_OBJECT(field, object) ##__VA_ARGS__)
+       SCRIPT(args, "GPRINT:" FIELD ":" format, FIELD_AND_OBJECT(field, object), ##__VA_ARGS__)
 #define PRINT_EOL(args)                                                                        SCRIPT(args, "COMMENT:" EOL)
 
 /*
@@ -413,7 +414,7 @@ static inline int __DRAW(td_args* args, const char* what, const char* field,
 #define __DRAW_IO_BYTES(args, object, bytes, color, label, ...) \
        do { \
                DRAW_AREA_WITH_LABEL(args, bytes, object, color, 0, label, __VA_ARGS__); \
-               PRINT_CAMM(args, bytes, object, BYTES); \
+               PRINT_CAMM(args, bytes, object, BYTES, BYTES_UNIT); \
        } while (0)
 
 /*
index 1a8b5c75cc4f5170d316f76ba456f9573a5edd92..b1ef29a3d0ed08cbe303ca4d57d8d4d9bde8bc23 100644 (file)
@@ -47,23 +47,23 @@ static int unbound_memory_usage_render(td_ctx* ctx, td_graph* graph,
        // Draw the area outlines afterwards
        DRAW_AREA_OUTLINE_WITH_LABEL(args, "mem_mod_respip", NULL,
                COLOR_DNS_RPZ, 0, _("Request Policy Zones"));
-       PRINT_CAMM(args, "mem_mod_respip", NULL, BYTES);
+       PRINT_CAMM(args, "mem_mod_respip", NULL, BYTES, BYTES_UNIT);
 
        DRAW_AREA_OUTLINE_WITH_LABEL(args, "mem_mod_validator", NULL,
                COLOR_DNS_VALIDATOR, STACKED, _("Validator"));
-       PRINT_CAMM(args, "mem_mod_validator", NULL, BYTES);
+       PRINT_CAMM(args, "mem_mod_validator", NULL, BYTES, BYTES_UNIT);
 
        DRAW_AREA_OUTLINE_WITH_LABEL(args, "mem_mod_iterator", NULL,
                COLOR_DNS_ITERATOR, STACKED, _("Iterator"));
-       PRINT_CAMM(args, "mem_mod_iterator", NULL, BYTES);
+       PRINT_CAMM(args, "mem_mod_iterator", NULL, BYTES, BYTES_UNIT);
 
        DRAW_AREA_OUTLINE_WITH_LABEL(args, "mem_cache_rrset", NULL,
                COLOR_DNS_RRSETS, STACKED, _("RRSet Objects"));
-       PRINT_CAMM(args, "mem_cache_rrset", NULL, BYTES);
+       PRINT_CAMM(args, "mem_cache_rrset", NULL, BYTES, BYTES_UNIT);
 
        DRAW_AREA_OUTLINE_WITH_LABEL(args, "mem_cache_message", NULL,
                COLOR_DNS_MSGS, STACKED, _("Message Objects"));
-       PRINT_CAMM(args, "mem_cache_message", NULL, BYTES);
+       PRINT_CAMM(args, "mem_cache_message", NULL, BYTES, BYTES_UNIT);
 
        PRINT_EMPTY_LINE(args);