Pulse/pkg/proxmox
rcourtman af55362009 Fix inflated RAM usage reporting for LXC containers
Related to #553

## Problem

LXC containers showed inflated memory usage (e.g., 90%+ when actual usage was 50-60%,
96% when actual was 61%) because the code used the raw `mem` value from Proxmox's
`/cluster/resources` API endpoint. This value comes from cgroup `memory.current` which
includes reclaimable cache and buffers, making memory appear nearly full even when
plenty is available.

## Root Cause

- **Nodes**: Had sophisticated cache-aware memory calculation with RRD fallbacks
- **VMs (qemu)**: Had detailed memory calculation using guest agent meminfo
- **LXCs**: Naively used `res.Mem` directly without any cache-aware correction

The Proxmox cluster resources API's `mem` field for LXCs includes cache/buffers
(from cgroup memory accounting), which should be excluded for accurate "used" memory.

## Solution

Implement cache-aware memory calculation for LXC containers by:

1. Adding `GetLXCRRDData()` method to fetch RRD metrics for LXC containers from
   `/nodes/{node}/lxc/{vmid}/rrddata`
2. Using RRD `memavailable` to calculate actual used memory (total - available)
3. Falling back to RRD `memused` if `memavailable` is not available
4. Only using cluster resources `mem` value as last resort

This matches the approach already used for nodes and VMs, providing consistent
cache-aware memory reporting across all resource types.

## Changes

- Added `GuestRRDPoint` type and `GetLXCRRDData()` method to pkg/proxmox
- Added `GetLXCRRDData()` to ClusterClient for cluster-aware operations
- Modified LXC memory calculation in `pollPVEInstance()` to use RRD data when available
- Added guest memory snapshot recording for LXC containers
- Updated test stubs to implement the new interface method

## Testing

- Code compiles successfully
- Follows the same proven pattern used for nodes and VMs
- Includes diagnostic snapshot recording for troubleshooting
2025-11-06 00:16:18 +00:00
..
ceph.go Fix settings security tab navigation 2025-10-11 23:29:47 +00:00
client.go Fix inflated RAM usage reporting for LXC containers 2025-11-06 00:16:18 +00:00
client_test.go Add replication monitoring plumbing and UI 2025-10-22 16:10:15 +00:00
cluster_client.go Fix inflated RAM usage reporting for LXC containers 2025-11-06 00:16:18 +00:00
cluster_client_test.go security: complete Phase 1 sensor proxy hardening 2025-10-20 15:13:37 +00:00
replication.go Add replication monitoring plumbing and UI 2025-10-22 16:10:15 +00:00
zfs.go Fix false ZFS log/cache warnings 2025-10-14 20:57:43 +00:00
zfs_test.go Expand monitoring and discovery test coverage 2025-10-16 08:17:08 +00:00