HEX
Server: nginx/1.29.3
System: Linux 11979.bigscoots-wpo.com 6.8.0-88-generic #89-Ubuntu SMP PREEMPT_DYNAMIC Sat Oct 11 01:02:46 UTC 2025 x86_64
User: nginx (1068)
PHP: 7.4.33
Disabled: exec,system,passthru,shell_exec,proc_open,proc_close,popen,show_source,cmd# Do not modify this line # 1684243876
Upload Files
File: //bigscoots/lxd/arc-suggest.sh
#!/bin/bash
echo "--- FLEET HEALTH AUDIT: $(hostname) ---"

# 1. Check Real Memory Pressure
PSI=$(tail -n 1 /proc/pressure/memory | awk '{print $2}' | cut -d= -f2)
echo "Memory Pressure (Avg10): $PSI"

# 2. Memory & ARC Analysis
TOTAL_RAM_GB=$(free -g | awk '/^Mem:/{print $2}')
ARC_MAX=$(cat /sys/module/zfs/parameters/zfs_arc_max)
ARC_MAX_GB=$(echo "scale=2; $ARC_MAX / 1024 / 1024 / 1024" | bc)

if [ "$TOTAL_RAM_GB" -le 16 ]; then SUGGESTED_ARC=3
elif [ "$TOTAL_RAM_GB" -le 32 ]; then SUGGESTED_ARC=4
elif [ "$TOTAL_RAM_GB" -le 64 ]; then SUGGESTED_ARC=8
else
    SUGGESTED_ARC=$(echo "$TOTAL_RAM_GB * 0.10" | bc | cut -d. -f1)
    if [ "$SUGGESTED_ARC" -gt 32 ]; then SUGGESTED_ARC=32; fi
fi

SUGGESTED_BYTES=$(($SUGGESTED_ARC * 1024 * 1024 * 1024))
echo "Total System RAM: ${TOTAL_RAM_GB}GB"
echo "Current ARC Max: ${ARC_MAX_GB}GB"
echo "Suggested ARC:   ${SUGGESTED_ARC}GB"

if [ "$ARC_MAX" -eq 0 ] || [ "$ARC_MAX" -ne "$SUGGESTED_BYTES" ]; then
    echo ">>> FIX ARC:"
    echo "echo $SUGGESTED_BYTES > /sys/module/zfs/parameters/zfs_arc_max"
    echo "echo \"options zfs zfs_arc_max=$SUGGESTED_BYTES\" > /etc/modprobe.d/zfs.conf"
fi

# 3. Check Swappiness
SWAP_VAL=$(cat /proc/sys/vm/swappiness)
echo "Current Swappiness: $SWAP_VAL"
if [ "$SWAP_VAL" -gt 20 ]; then
    echo ">>> FIX SWAP:"
    echo "sysctl -w vm.swappiness=10"
    echo "echo 'vm.swappiness=10' >> /etc/sysctl.conf"
fi

# 4. Check for Thick Provisioned VMs
echo "Checking for Thick Provisioned VMs..."
THICK_VOLS=$(zfs list -t volume -o name,usedbyrefreservation -H | awk '$2 != "0" && $2 != "0B" {print $1}')
if [ -n "$THICK_VOLS" ]; then
    echo "[!] ALERT: Found Thick ZVOLs! Fix with:"
    for v in $THICK_VOLS; do echo "    zfs set refreservation=none $v"; done
else
    echo "No thick-provisioned ZVOLs found. Good."
fi

# 5. Check Pool Health
zpool list -H -o name,cap,frag | while read name cap frag; do
    echo "Pool $name: Capacity ${cap}, Fragmentation ${frag}"
done
echo "--- AUDIT COMPLETE ---"