rrd: cope with only partially renamed memavailable field

During initial development of the revised metrics series this field
was sourced by 'memfree' from /proc/meminfo as parsed by our ProcFS
tools, but as memavailable got added for PVE 8.4, as it much better
shows the state of actually available memory [0], I suggested to Aaron
to move the new RRD format also to that metric. While that was done,
the RRD definition was still using the old name, while I fixed in in
pmxcfs, I forgot to do so in the upgrade migration tool, which then
created an RRD file with the old name.

Thus map the old name to the new one here in case there is no existing
entry for the new one already, if one would be parsed later it would
override this fallback anyway.

[0] as while the kernel tries to use unused memory to improve
performance, it has no issue to release that again quickly on memory
pressure.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2025-08-04 11:43:52 +02:00
parent 63862b41c3
commit e2c572850b

View file

@ -37,6 +37,7 @@ sub create_rrd_data {
$setup = $setup_pve2;
$timeframe = "year" if $timeframe eq "decade"; # we only store up to one year in the old format
}
my $is_node = !!($rrdname =~ /^pve-node/);
my ($reso, $count) = @{ $setup->{$timeframe} };
my $ctime = $reso * int(time() / $reso);
@ -70,6 +71,8 @@ sub create_rrd_data {
my $name = $names->[$i];
if (defined(my $val = $line->[$i])) {
$entry->{$name} = $val;
$entry->{memavailable} = $val
if $is_node && $name eq 'memfree' && !exists($entry->{memavailable});
} else {
# leave empty fields undefined
# maybe make this configurable?