Create retention charts for higher tiers (#17855)
Allow creation of dbengine retention charts for higher tiers if applicable
Stelios Fragkakis committed
Jun 11, 2024 at 21:02 UTC
77358d9ee88eb861586aae106a950b22272eb8cf
2 files changed
+17
-4
src/daemon/service.c
+1
-2
@@ -315,8 +315,7 @@ void *service_main(void *ptr)
315
real_step = USEC_PER_SEC;
316
317
#ifdef ENABLE_DBENGINE
318
- if (default_rrd_memory_mode == RRD_MEMORY_MODE_DBENGINE)
319
- dbengine_retention_statistics();
318
+ dbengine_retention_statistics();
319
#endif
320
321
svc_rrd_cleanup_obsolete_charts_from_all_hosts();
src/database/engine/rrdengine.c
+16
-2
@@ -1780,10 +1780,18 @@ uint64_t get_directory_free_bytes_space(struct rrdengine_instance *ctx)
1780
1781
void calculate_tier_disk_space_percentage(void)
1782
{
1783
- static uint64_t tier_space[RRD_STORAGE_TIERS];
1783
+ uint64_t tier_space[RRD_STORAGE_TIERS];
1784
+
1785
+ if (!localhost)
1786
+ return;
1787
1788
uint64_t total_diskspace = 0;
1789
for(size_t tier = 0; tier < storage_tiers ;tier++) {
1790
+ STORAGE_ENGINE *eng = localhost->db[tier].eng;
1791
+ if (!eng || eng->seb != STORAGE_ENGINE_BACKEND_DBENGINE) {
1792
+ tier_space[tier] = 0;
1793
+ continue;
1794
+ }
1795
uint64_t tier_disk_space = multidb_ctx[tier]->config.max_disk_space ?
1796
multidb_ctx[tier]->config.max_disk_space :
1797
get_directory_free_bytes_space(multidb_ctx[tier]);
@@ -1803,9 +1811,16 @@ void dbengine_retention_statistics(void)
1811
static bool init = false;
1812
static DBENGINE_TIER_STATS stats[RRD_STORAGE_TIERS];
1813
1814
+ if (!localhost)
1815
+ return;
1816
+
1817
calculate_tier_disk_space_percentage();
1818
1819
for (size_t tier = 0; tier < storage_tiers; tier++) {
1820
+ STORAGE_ENGINE *eng = localhost->db[tier].eng;
1821
+ if (!eng || eng->seb != STORAGE_ENGINE_BACKEND_DBENGINE)
1822
+ continue;
1823
+
1824
if (init == false) {
1825
char id[200];
1826
snprintfz(id, sizeof(id) - 1, "dbengine_retention_tier%zu", tier);
@@ -1835,7 +1850,6 @@ void dbengine_retention_statistics(void)
1850
rrdset_metadata_updated(stats[tier].st);
1851
}
1852
1838
- STORAGE_ENGINE *eng = localhost->db[tier].eng;
1853
time_t first_time_s = storage_engine_global_first_time_s(eng->seb, localhost->db[tier].si);
1854
time_t retention = first_time_s ? now_realtime_sec() - first_time_s : 0;
1855