From 4c8e6fdfa6c0ddf7541f9a46411e7cb722d66f16 Mon Sep 17 00:00:00 2001 From: Idriss Neumann Date: Wed, 11 Sep 2024 15:13:14 +0100 Subject: [PATCH] Improve numeric metrics --- CONTRIBUTING.md | 4 ++-- src/utils/heartbit.py | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 374e32c..b54d698 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,13 +3,13 @@ For the developers you can test your changes on the app by running this command: ```shell -docker-compose -f docker-compose-local.yml up --build --force-recreate +docker-compose -f docker-compose-local.yml up --build --force-recreate ``` You can also run unit tests by running this command: ```shell -docker-compose -f docker-compose-local.yml up --build --abort-on-container-exit imalive-tests +docker-compose -f docker-compose-local.yml up --build --abort-on-container-exit imalive-tests ``` Then you can try: diff --git a/src/utils/heartbit.py b/src/utils/heartbit.py index 317cc6d..fb8561d 100644 --- a/src/utils/heartbit.py +++ b/src/utils/heartbit.py @@ -19,6 +19,7 @@ cpu_gauge = create_gauge("cpu_all", "cpu usage in percent") ram_total_gauge = create_gauge("ram_total", "total of ram") ram_available_gauge = create_gauge("ram_available", "available ram") +ram_used_gauge = create_gauge("ram_used", "used ram") ram_percent_gauge = create_gauge("ram_percent", "percent ram") disk_free_gauge = create_gauge("disk_free", "free storage's space") disk_used_gauge = create_gauge("disk_used", "used storage's space") @@ -36,16 +37,17 @@ def cpu(metrics): def ram(metrics): memory_usage_percent = metrics['virtual_memory']['percent'] - set_gauge(ram_total_gauge, metrics['virtual_memory']['total']) - set_gauge(ram_available_gauge, metrics['virtual_memory']['available']) + set_gauge(ram_total_gauge, metrics['virtual_memory']['numeric']['total']) + set_gauge(ram_available_gauge, metrics['virtual_memory']['numeric']['available']) + set_gauge(ram_used_gauge, metrics['virtual_memory']['numeric']['used']) set_gauge(ram_percent_gauge, memory_usage_percent) check_and_log_usage('Memory', memory_usage_percent, WARNING_THRESHOLD, ERROR_THRESHOLD) def swap(metrics): swap_usage_percent = metrics['swap_memory']['percent'] - set_gauge(swap_free_gauge, metrics['swap_memory']['free']) - set_gauge(swap_used_gauge, metrics['swap_memory']['used']) - set_gauge(swap_total_gauge, metrics['swap_memory']['total']) + set_gauge(swap_free_gauge, metrics['swap_memory']['numeric']['free']) + set_gauge(swap_used_gauge, metrics['swap_memory']['numeric']['used']) + set_gauge(swap_total_gauge, metrics['swap_memory']['numeric']['total']) set_gauge(swap_percent_gauge, swap_usage_percent) check_and_log_usage('Swap', swap_usage_percent, WARNING_THRESHOLD, ERROR_THRESHOLD)