| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | #ifndef NETDATA_RRD_RETENTION_H |
| 4 | #define NETDATA_RRD_RETENTION_H |
| 5 | |
| 6 | #include "libnetdata/libnetdata.h" |
| 7 | #include "storage-engine.h" |
| 8 | |
| 9 | // Structure to hold information about each storage tier |
| 10 | typedef struct rrd_storage_tier { |
| 11 | size_t tier; // Tier number |
| 12 | STORAGE_ENGINE_BACKEND backend; // Storage engine backend (RRDDIM or DBENGINE) |
| 13 | size_t group_seconds; // Granularity in seconds |
| 14 | char granularity_human[32]; // Human-readable granularity string |
| 15 | |
| 16 | size_t metrics; // Number of metrics in this tier |
| 17 | size_t samples; // Number of samples in this tier |
| 18 | |
| 19 | uint64_t disk_used; // Disk space used in bytes |
| 20 | uint64_t disk_max; // Maximum available disk space in bytes |
| 21 | double disk_percent; // Disk usage percentage (0.0-100.0) |
| 22 | |
| 23 | time_t first_time_s; // Oldest timestamp in this tier |
| 24 | time_t last_time_s; // Most recent timestamp in this tier |
| 25 | time_t retention; // Current retention in seconds (last_time_s - first_time_s) |
| 26 | char retention_human[32]; // Human-readable current retention |
| 27 | |
| 28 | time_t requested_retention; // Configured maximum retention in seconds |
| 29 | char requested_retention_human[32]; // Human-readable configured retention |
| 30 | |
| 31 | time_t expected_retention; // Expected retention based on current usage |
| 32 | char expected_retention_human[32]; // Human-readable expected retention |
| 33 | } RRD_STORAGE_TIER; |
| 34 | |
| 35 | // Main structure to hold retention information across all tiers |
| 36 | typedef struct rrdstats_retention { |
| 37 | size_t storage_tiers; // Number of available storage tiers |
| 38 | RRD_STORAGE_TIER tiers[RRD_STORAGE_TIERS]; // Array of tier information |
| 39 | } RRDSTATS_RETENTION; |
| 40 | |
| 41 | // Function to collect retention statistics |
| 42 | RRDSTATS_RETENTION rrdstats_retention_collect(void); |
| 43 | |
| 44 | #endif // NETDATA_RRD_RETENTION_H |