75 lines
2.0 KiB
Bash
75 lines
2.0 KiB
Bash
|
#!/bin/sh
|
||
|
|
||
|
# Copyright (c) 2018-2021, diyIT.org
|
||
|
# All rights reserved.
|
||
|
#
|
||
|
# BSD 2-Clause License ("Simplified BSD License" or "FreeBSD License")
|
||
|
# https://diyit.org/license/
|
||
|
#
|
||
|
#
|
||
|
|
||
|
MCLBYTES=2048
|
||
|
MSIZE=256
|
||
|
PHYSMEM=`sysctl -n hw.physmem`
|
||
|
PAGE_SIZE=`sysctl -n hw.pagesize`
|
||
|
VM_KMEM_SIZE=`sysctl -n vm.kmem_size`
|
||
|
REALMEM=${VM_KMEM_SIZE}
|
||
|
MAXMBUFMEM=`expr $REALMEM / 4 \* 3`
|
||
|
MJUMPAGESIZE=$PAGE_SIZE
|
||
|
MJUM9BYTES=`expr 9 \* 1024`
|
||
|
MJUM16BYTES=`expr 16 \* 1024`
|
||
|
|
||
|
#NMBCLUSTERS=`expr $MAXMBUFMEM / $MCLBYTES / 4` # higher # of jails
|
||
|
NMBCLUSTERS=`expr $MAXMBUFMEM / $MCLBYTES / 3`
|
||
|
NMBJUMBOP=`expr $MAXMBUFMEM / $MJUMPAGESIZE / 4`
|
||
|
NMBJUMBO9=`expr $MAXMBUFMEM / $MJUM9BYTES / 6`
|
||
|
NMBJUMBO16=`expr $MAXMBUFMEM / $MJUM16BYTES / 6`
|
||
|
|
||
|
NMBUFS=`sysctl -n kern.ipc.nmbufs`
|
||
|
NMMAX1=`expr $NMBCLUSTERS + $NMBJUMBOP + $NMBJUMBO9 + $NMBJUMBO16`
|
||
|
NMMAX2=`expr $MAXMBUFMEM / $MSIZE / 5`
|
||
|
if [ $NMMAX1 -gt $NMMAX2 ]; then
|
||
|
NMBUFS=$NMMAX1
|
||
|
else
|
||
|
NMBUFS=$NMMAX2
|
||
|
fi
|
||
|
|
||
|
show()
|
||
|
{
|
||
|
echo "# `basename $0 ` suggested settings:"
|
||
|
echo "kern.ipc.maxmbufmem=$MAXMBUFMEM"
|
||
|
echo "kern.ipc.nmbclusters=$NMBCLUSTERS"
|
||
|
echo "kern.ipc.nmbjumbop=$NMBJUMBOP"
|
||
|
echo "kern.ipc.nmbjumbo9=$NMBJUMBO9"
|
||
|
echo "kern.ipc.nmbjumbo16=$NMBJUMBO16"
|
||
|
echo "kern.ipc.nmbufs=$NMBUFS"
|
||
|
}
|
||
|
|
||
|
compare()
|
||
|
{
|
||
|
echo "kern.ipc.maxmbufmem: `sysctl -n kern.ipc.maxmbufmem` (current)"
|
||
|
echo " --> $MAXMBUFMEM (suggested)"
|
||
|
echo "kern.ipc.nmbclusters: `sysctl -n kern.ipc.nmbclusters`"
|
||
|
echo " --> $NMBCLUSTERS"
|
||
|
echo "kern.ipc.nmbjumbop: `sysctl -n kern.ipc.nmbjumbop`"
|
||
|
echo " --> $NMBJUMBOP"
|
||
|
echo "kern.ipc.nmbjumbo9: `sysctl -n kern.ipc.nmbjumbo9`"
|
||
|
echo " --> $NMBJUMBO9"
|
||
|
echo "kern.ipc.nmbjumbo16: `sysctl -n kern.ipc.nmbjumbo16`"
|
||
|
echo " --> $NMBJUMBO16"
|
||
|
echo "kern.ipc.nmbufs: `sysctl -n kern.ipc.nmbufs`"
|
||
|
echo " --> $NMBUFS"
|
||
|
vmstat -z|grep -E '^ITEM|mbuf'
|
||
|
netstat -m
|
||
|
# vmstat -m
|
||
|
}
|
||
|
|
||
|
if [ $# -gt 0 ]; then
|
||
|
if [ $1 == '-c' ]; then
|
||
|
compare
|
||
|
exit 0
|
||
|
fi
|
||
|
fi
|
||
|
|
||
|
show
|