]> git.ipfire.org Git - collecty.git/commitdiff
graphs: memory: Convert bytes correctly based on 1024
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 29 Oct 2025 17:08:59 +0000 (17:08 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 29 Oct 2025 17:08:59 +0000 (17:08 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/graph.c
src/daemon/graph.h
src/daemon/graphs/memory.c

index 8d6f7117eac568e404ac4cb8233dba0e8eb6e35e..f93176d46868ba5a9992d2d7f6d15301184c0d2e 100644 (file)
@@ -304,6 +304,13 @@ int td_graph_render(td_graph* self, const char* object,
        if (r < 0)
                goto ERROR;
 
+       // Set base
+       if (self->impl->base) {
+               r = td_args_push(args, "--base=%d", self->impl->base);
+               if (r < 0)
+                       goto ERROR;
+       }
+
        // Set lower limit
        if (self->impl->lower_limit > -LONG_MAX) {
                r = td_args_push(args, "--lower-limit=%ld", self->impl->lower_limit);
index 01d3a8be44f8410ff3d3696f0dbd3bdede392021..739bc5e635b8f7998536dfb9de963d10478c8132 100644 (file)
@@ -41,6 +41,9 @@ typedef struct td_graph_impl {
        long lower_limit;
        long upper_limit;
 
+       // Base
+       int base;
+
        // Available
        int (*available)(td_ctx* ctx, td_daemon* daemon);
 
index c1883d054679e073d0126e4b1fa8624b6bbe069d..0fa456bded3b0350368e48c5df57306fdee5733f 100644 (file)
@@ -107,6 +107,7 @@ const td_graph_impl memory_graph = {
        .render  = memory_render,
        .title   = memory_title,
        .vlabel  = memory_vlabel,
+       .base    = 1024,
 
        // Limits
        .lower_limit = 0,