bash-3.00# mdb -k
Loading modules: [ unix krtld genunix specfs dtrace cpu.AuthenticAMD.15 ufs md ip sctp usba fcp fctl lofs zfs random nfs crypto fcip cpc logindmux ptm ipc ]
> ::memstat
Page Summary Pages MB %Tot
------------ ---------------- ---------------- ----
Kernel 859062 3355 41%
Anon 675625 2639 32%
Exec and libs 7994 31 0%
Page cache 39319 153 2%
Free (cachelist) 110881 433 5%
Free (freelist) 385592 1506 19%
Total 2078473 8119
Physical 2049122 8004
>
bash-3.00# echo "::kmastat"|mdb -k|grep zio_buf|awk 'BEGIN {c=0} {c=c+$5} END {print c}'
2923298816
So kernel consumes about 3.2TB of memory and about 2.7GB is allocated to ZFS buffers and basically should be treated as free memory. Approximately free memory on this host is: Free (cachelist) + Free (freelist) + 2923298816.
I guess small script which do all the calculations automatically would be useful.
#!/bin/ksh
ReplyDelete# ZFS I/O buffer (can be treated as free memory)
ZIO_BUF=`echo "::kmastat"|mdb -k|grep zio_buf|awk 'BEGIN {c=0} {c=c+$5} END {pri
nt c}'`
((ZFS_BUF = $ZIO_BUF / 1024 / 1024 ))
# Free memory from cachelist and freelist out of memstat
FREE=`echo "::memstat"|mdb -k|grep Free|awk 'BEGIN {c=0} {c=c+$4} END {print c}'
`
((FREE_MEM = $ZFS_BUF + $FREE ))
echo "Free memory = $FREE_MEM MB"
A faster (and less resource intensive method) is :
ReplyDeletekstat -p zfs:0:arcstats:size
So:
FREE=$(($(pagesize)*$(kstat -p unix:0:system_pages:freemem|awk '{print $NF}')))
ZIO_BUF=$(kstat -p zfs:0:arcstats:size|awk '{print $NF}')
FREE_MEM=$((FREE+ZIO_BUF))