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.

631 B
Raw Blame
//go:build freebsd

package hostmetrics

import (
	"encoding/binary"
	"fmt"

	"golang.org/x/sys/unix"
)

func readARCSize() (uint64, error) {
	// kstat.zfs.misc.arcstats.size holds the current ARC size in bytes.
	// This is a uint64 sysctl on FreeBSD.
	raw, err := unix.SysctlRaw("kstat.zfs.misc.arcstats.size")
	if err != nil {
		return 0, err
	}

	switch len(raw) {
	case 8:
		return binary.NativeEndian.Uint64(raw), nil
	case 4:
		// Defensive: some environments may expose a 32-bit value.
		return uint64(binary.NativeEndian.Uint32(raw)), nil
	default:
		return 0, fmt.Errorf("unexpected sysctl value size: %d", len(raw))
	}
}