[PATCH pve-ha-manager v2 5/6] api: status: add load imbalance to status

Dominik Rusovac
2026-04-29T12:21:58Z

This is a very basic measure to enable users to detect the prevailing
load imbalance in the UI, which atm reveals nothing about the latter.

imo, enabling users to track how the load imbalance changed over time
(using RRD graphs, for example) should be considered, in the long run.

Signed-off-by: Dominik Rusovac <d.rusovac@proxmox.com>
---

Notes:
changes since v1:
* check whether load balancing system is enabled
* binding $crs->{ha} to $mode

src/PVE/API2/HA/Status.pm | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/PVE/API2/HA/Status.pm b/src/PVE/API2/HA/Status.pm
index 4894f3b..8dadff3 100644
--- a/src/PVE/API2/HA/Status.pm
+++ b/src/PVE/API2/HA/Status.pm
@@ -199,8 +199,11 @@ __PACKAGE__->register_method({
}
my $datacenter_config = eval { cfs_read_file('datacenter.cfg') } // {};
if (my $crs = $datacenter_config->{crs}) {
- $extra_status .= " - $crs->{ha} load CRS"
- if $crs->{ha} && $crs->{ha} ne 'basic';
+ my $mode = $crs->{ha};
+ $extra_status .=
+ " - $mode load CRS "
+ . sprintf("(load imbalance: %.2f", 100 * $status->{imbalance}) . "%)"
+ if $crs->{'ha-auto-rebalance'} && $mode && $mode ne 'basic';
}
my $time_str = localtime($status->{timestamp});
my $status_text = "$master ($status_str, $time_str)$extra_status";
--
2.47.3