#!/bin/sh
#
# gold_kctune.sh
#
# This is a simple script that you can run on each of your servers to ensure 
# that they all have a configuration with minimal kernel values.
#
# Modify to your taste.
# Modify to your taste.
#

if [ ! -d /stand/vanilla ]
then
	kconfig -C "Save initial HP-UX installation" -s vanilla
	kconfig -t vanilla "HP-UX vanilla kernel"
fi

semmni=4096
nproc=4200
msgtql=4200

# shmmax=qte de memoire dans le serveur. Requis pour Oracle 10g
shmmax=$(machinfo | awk '/Memory =/ {memMb=$3; memb=$3 * 1048576; printf("%.0f",memb);}')
if [ $shmmax = "" ]
then
	echo "Problems determining shmmax, I must quit, sorry..."
	exit 1
fi

# This runs kctune with values that I would like to have in my kernel
kctune -B -C "My Oracle 10G and Java Configuration" dbc_max_pct=5 dbc_min_pct=2 nproc=${nproc} semmni=${semmni} msgtql=${msgtql} ksi_alloc_max=$((${nproc}*8)) max_thread_proc\>=3000 maxdsiz\>=2063835136 maxdsiz_64bit\>=1073741824 maxssiz\>=134217728 maxssiz_64bit\>=1073741824 maxuprc\>=$(((${nproc}*9)/10)) maxvgs\>=64 msgmap\>=$((${msgtql}+2)) msgmni\>=${nproc} msgseg\>=32767 ncsize\>=$((8*${nproc}+2048+1024)) nfile=Default nflock=Default ninode\>=$((8*${nproc}+2048)) nkthread\>=$((((${nproc}*7)/4)+16)) nproc\>=4096 semmns\>=$((${semmni}*2)) semmnu\>=$((${nproc}-4)) semvmx\>=32768 shmmax\>=$shmmax shmmni\>=512 shmseg\>=32 st_san_safe=1 swchunk\>=4096 vps_ceiling\>=64 

# This adds two modules which are not installed by default: stape and schgr
kcmodule -B -C "Adding optional drivers" stape=best schgr=best

exit 0

