From faa784b0ee49bfd3a1fa3bb97807e5a69f6e66ad Mon Sep 17 00:00:00 2001 From: Lord Of Nougate Date: Thu, 2 Jun 2022 06:26:09 +0000 Subject: [PATCH] Added PVE mem-overview script Added mem-overview script for use on proxmox ve server. Added here, so I could remove an otherwise unused repository. --- pve_mem-overview.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 pve_mem-overview.sh diff --git a/pve_mem-overview.sh b/pve_mem-overview.sh new file mode 100644 index 0000000..1c8b1dc --- /dev/null +++ b/pve_mem-overview.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Memory state with use of "free" +MEM_TOTAL=$(free -m | awk '/^Mem:/ { print $2 } ') +MEM_USED=$(free -m | awk '/^Mem:/ { print $3 } ') + +# ARC state with use of "/proc/spl/kstat/zfs/arcstats" +FLOAT_ARC_USED=$(awk '/^size/ { print $3 / 1048576 }' < /proc/spl/kstat/zfs/arcstats) +INT_ARC_USED=${FLOAT_ARC_USED%.*} + +# Calculated values +MEM_SYSTEM=$(($MEM_USED-INT_ARC_USED)) +MEM_AVAILABLE=$(($MEM_TOTAL-$MEM_SYSTEM)) + +# output +echo -e "\nMemory overview:\n" +printf "\nTotal Memory:,Used Memory:,Available Memory:,Memory ARC:,Memory Sys & KVM:\n$MEM_TOTAL MiB,$MEM_USED MiB,$MEM_AVAILABLE MiB,$INT_ARC_USED MiB,$MEM_SYSTEM MiB\n\n" | column -t -s ',' + +echo -e "\nOutput definition:" + +echo -e "Total Memory: Memory installed on system +Available Memory: ['Total Memory' - 'Memory Sys & KVM'] +Memory ARC: Memory used by ZFS RAM cache (ARC) +Memory Sys & KVM: Memory used by containers, VMs and system\n" | column -t -s ' ' +