Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

853 B
Raw Blame
package monitoring

import "github.com/rcourtman/pulse-go-rewrite/internal/models"

// splitReclaimableMemory splits the reclaimable page cache out of a memory
// snapshot whose Free currently holds "available" (Total - Used, with Used
// already excluding cache). trulyFree is the node/guest-reported free page
// count; when it is known and smaller than Free, the gap is reclaimable
// buff/cache and the snapshot becomes used | cache | free, which is what the
// frontend memory bar needs to reconcile Pulse's percentage with the
// cache-inclusive number the Proxmox UI shows.
func splitReclaimableMemory(memory *models.Memory, trulyFree uint64) {
	if memory == nil || trulyFree == 0 {
		return
	}
	if memory.Free <= 0 || int64(trulyFree) >= memory.Free {
		return
	}
	memory.Cache = memory.Free - int64(trulyFree)
	memory.Free = int64(trulyFree)
}